40 #ifndef CASCODA_INTERFACE_H
41 #define CASCODA_INTERFACE_H
56 #ifndef CASCODA_CHILI2_CONFIG
57 #error CASCODA_CHILI2_CONFIG has to be defined! Please include the file "cascoda_chili_config.h"
75 #if ((CASCODA_CHILI2_CONFIG == 3) || (CASCODA_CHILI2_CONFIG == 4))
185 #define MSP_DEFAULT P_NA, P_NA, P_NA, P_NA
201 #if CASCODA_EXTERNAL_FLASHCHIP_PRESENT
207 typedef struct ExternalFlashInfo
210 u32_t readWriteLimit;
215 typedef ca_error (*ExternalFlashCallback)(
void *aContext);
218 struct ExternalFlashStatus
221 bool writeEnabled : 1;
225 typedef enum ExternalFlashPartialEraseType
230 } ExternalFlashPartialEraseType;
257 void BSP_USBSerialWrite(
u8_t *pBuffer);
264 u8_t *BSP_USBSerialRxPeek(
void);
269 void BSP_USBSerialRxDequeue(
void);
272 #if defined(USE_UART)
281 void BSP_SerialWriteAll(
u8_t *pBuffer,
u32_t BufferSize);
298 void BSP_SerialWaitWhileBusy(
void);
708 #if CASCODA_EXTERNAL_FLASHCHIP_PRESENT
The main ca821x-api include file.
ca_error BSP_ExternalFlashGetStatus(struct ExternalFlashStatus *status)
Definition: cascoda_bsp_w25q80dlsnig.c:805
void BSP_ExternalFlashGetInfo(struct ExternalFlashInfo *aFlashInfoOut)
Definition: cascoda_bsp_w25q80dlsnig.c:854
ca_error BSP_ExternalFlashPartialErase(ExternalFlashPartialEraseType aEraseType, uint32_t aAddress)
Definition: cascoda_bsp_w25q80dlsnig.c:731
ca_error BSP_ExternalFlashReadData(uint32_t aStartAddress, uint8_t aNumOfBytes, uint8_t *aRxData)
Definition: cascoda_bsp_w25q80dlsnig.c:708
ca_error BSP_ExternalFlashGetDeviceId(uint8_t *aId)
Definition: cascoda_bsp_w25q80dlsnig.c:788
ca_error BSP_ExternalFlashChipErase(void)
Definition: cascoda_bsp_w25q80dlsnig.c:766
void BSP_ExternalFlashInit(void)
Definition: cascoda_bsp_w25q80dlsnig.c:666
ca_error BSP_ExternalFlashProgram(uint32_t aStartAddress, uint8_t aNumOfBytes, uint8_t *aTxData)
Definition: cascoda_bsp_w25q80dlsnig.c:682
ca_error BSP_ExternalFlashScheduleCallback(ExternalFlashCallback aCallback, void *aContext)
Definition: cascoda_bsp_w25q80dlsnig.c:829
This file defines the flash interface used by settings.cpp.
Declarations for core platform abstraction functions.
unsigned long long u64_t
Definition: cascoda_types.h:52
unsigned long u32_t
Definition: cascoda_types.h:50
unsigned char u8_t
Definition: cascoda_types.h:46
signed long long i64_t
Definition: cascoda_types.h:53
signed long i32_t
Definition: cascoda_types.h:51
unsigned short u16_t
Definition: cascoda_types.h:48
void BSP_Initialise(struct ca821x_dev *pDeviceRef)
Initialise the system for a given ca821x_dev.
Definition: cascoda_bsp_chili.c:651
void BSP_DisableUSB(void)
Disable the USB.
Definition: cascoda_bsp_chili.c:766
module_pin_irq
Pin Interrupt.
Definition: cascoda_interface.h:139
void(* dispatch_read_t)(struct ca821x_dev *pDeviceRef)
Definition: cascoda_interface.h:188
void BSP_GetFlashInfo(struct ca_flash_info *aFlashInfoOut)
Get the flashinfo struct for the current platform.
Definition: cascoda_dataflash_nano120.c:62
ca_error BSP_FlashErase(u32_t startaddr)
Erases a Dataflash Memory page (All words in page set to 0xFFFFFFFF)
Definition: cascoda_dataflash_nano120.c:182
ca_error BSP_ModuleReadVoltsPin(u8_t mpin, u32_t *val)
Reads ADC Conversion Value on Module Pin.
Definition: cascoda_gpio_chili.c:622
void BSP_WatchdogDisable(void)
Watchdog Disable.
Definition: cascoda_bsp_chili.c:735
ca_error BSP_ModuleSenseGPIOPinOutput(u8_t mpin, u8_t *val)
Senses GPIO Output Value of Module Pin.
Definition: cascoda_gpio_chili.c:629
fsys_mhz
Definition: cascoda_interface.h:62
ca_error BSP_ModuleRegisterGPIOInput(struct gpio_input_args *args)
Registers GPIO Input Functionality for Module Pin.
Definition: cascoda_gpio_chili.c:297
struct ModuleSpecialPins BSP_GetModuleSpecialPins(void)
Get the struct of special pins for the platform.
Definition: cascoda_gpio_chili.c:130
void BSP_EnableUSB(void)
Enable the USB if connected.
Definition: cascoda_bsp_chili.c:753
u8_t BSP_IsUSBPresent(void)
Is the USB connected?
Definition: cascoda_bsp_chili.c:779
ca_error BSP_FlashRead(u32_t startaddr, u32_t *data, u32_t datasize)
Reads Dataflash Memory.
Definition: cascoda_dataflash_nano120.c:217
u32_t BSP_ADCGetVolts(void)
Measure and Read Battery Volts Value from ADC.
Definition: cascoda_bsp_chili.c:333
void BSP_RTCGetDateAndTime(struct RTCDateAndTime *dateandtime)
Gets RTC Date+Time.
Definition: cascoda_rtc_m2351_secure.c:332
sysreset_mode
Definition: cascoda_interface.h:103
u8_t BSP_GetVBUSConnected(void)
Get USB VBUS status (connected/not connected)
Definition: cascoda_bsp_chili.c:294
module_pin_dir
Pin Type.
Definition: cascoda_interface.h:111
u64_t BSP_GetUniqueId(void)
Get a 64-bit ID that is unique to this device.
Definition: cascoda_bsp_chili.c:247
ca_error BSP_RTCSetDateAndTime(struct RTCDateAndTime dateandtime)
Sets RTC Date+Time.
Definition: cascoda_rtc_m2351_secure.c:310
u8_t BSP_ModuleIsGPIOPinRegistered(u8_t mpin)
Checks if a Module Pin is already registered / used.
Definition: cascoda_gpio_chili.c:553
void BSP_SystemReset(sysreset_mode resetMode)
**OPTIONAL Function Declarations for cascoda_bsp_*.c
Definition: cascoda_bsp_chili.c:630
void BSP_RTCConvertSecondsToDateAndTime(i64_t seconds, struct RTCDateAndTime *dateandtime)
Converts Unix Time seconds to RTC Date+Time.
Definition: cascoda_rtc_m2351_secure.c:345
wakeup_reason BSP_GetWakeupReason(void)
Reason MCU has woken up after reset.
Definition: cascoda_bsp_chili.c:594
ca_error BSP_SetBootMode(sysreset_mode bootMode)
Set the default boot mode for the device.
Definition: cascoda_bsp_chili.c:636
void BSP_EnableSerialIRQ(void)
Enable the serial (usb/uart) irq.
Definition: cascoda_bsp_chili.c:162
module_pin_type
Pin is LED?
Definition: cascoda_interface.h:132
void BSP_DisableSerialIRQ(void)
Disable the serial (usb/uart) irq.
Definition: cascoda_bsp_chili.c:175
ca_error BSP_ModuleRegisterGPIOSharedInputOutputOD(struct gpio_input_args *args, module_pin_type isled)
Registers GPIO Input AND Open Drain Output Functionality for Module Pin.
Definition: cascoda_gpio_chili.c:428
u8_t BSP_IsWatchdogTriggered(void)
Checks if the watchdog has been triggered, clears the warning if so.
Definition: cascoda_bsp_chili.c:724
void BSP_SetPowerDown(void)
Set flag that system has started power-down sequence.
Definition: cascoda_bsp_chili.c:566
void BSP_RTCDisableAlarm(void)
Disables RTC Alarm.
Definition: cascoda_rtc_m2351_secure.c:305
ca_error BSP_ModuleDeregisterGPIOPin(u8_t mpin)
Unregisters GPIO Functionality for Module Pin to Default Settings.
Definition: cascoda_gpio_chili.c:522
ca_error BSP_FlashCheck(u32_t startaddr, u32_t checklen, u32_t crc32)
Check that a given range of flash matches the provided CRC32 checksum.
Definition: cascoda_dataflash_nano120.c:242
ca_error BSP_ModuleSetGPIOPin(u8_t mpin, u8_t val)
Sets Module Pin GPIO Output Value.
Definition: cascoda_gpio_chili.c:564
ca_error BSP_ModuleRegisterGPIOOutputOD(u8_t mpin, module_pin_type isled)
Registers GPIO Open Drain Output Functionality for Module Pin.
Definition: cascoda_gpio_chili.c:397
ca_error BSP_ModuleRegisterGPIOOutput(u8_t mpin, module_pin_type isled)
Registers GPIO Output Functionality for Module Pin.
Definition: cascoda_gpio_chili.c:366
void BSP_WatchdogReset(void)
Watchdog Reset and Restart.
Definition: cascoda_bsp_chili.c:712
module_pin_not_available
Definition: cascoda_interface.h:147
fsys_mhz BSP_GetSystemFrequency(void)
Returns the system frequency.
Definition: cascoda_bsp_chili.c:787
void BSP_FlashLock(void)
Prevent ICP access to Flash.
Definition: cascoda_bsp_chili.c:808
u8_t BSP_GetChargeStat(void)
Get Microchip MCP73831 Charge Status.
Definition: cascoda_bsp_chili.c:275
ca_error BSP_ModuleSetGPIOOutputPermanent(u8_t mpin)
Sets Module Pin GPIO Output as permanently driven (don't tristate in Power-Down)
Definition: cascoda_gpio_chili.c:602
void BSP_PowerDown(u32_t sleeptime_ms, u8_t use_timer0, dpd_flag dpd)
Set up wake on timer/IRQ, Power down MCU and return on wakeup.
Definition: cascoda_bsp_chili.c:451
module_pin_pullup
Pin Pull-Up.
Definition: cascoda_interface.h:118
void BSP_RTCInitialise(void)
Initialises RTC.
Definition: cascoda_rtc_m2351_secure.c:239
ca_error BSP_ModuleSenseGPIOPin(u8_t mpin, u8_t *val)
Senses GPIO Input Value of Module Pin.
Definition: cascoda_gpio_chili.c:583
i32_t BSP_GetTemperature(void)
Measure and Read Temperature Value.
Definition: cascoda_bsp_chili.c:302
wakeup_reason
Definition: cascoda_interface.h:84
module_pin_debounce
Pin Debounce.
Definition: cascoda_interface.h:125
ca_error BSP_FlashWriteInitial(u32_t startaddr, void *data, u32_t datasize)
Writes Dataflash Memory, relies on Memory erased.
Definition: cascoda_dataflash_nano120.c:151
i64_t BSP_RTCConvertDateAndTimeToSeconds(const struct RTCDateAndTime *dateandtime)
Converts RTC Date+Time to Unix Time seconds.
Definition: cascoda_rtc_m2351_secure.c:358
void BSP_WatchdogEnable(u32_t timeout_ms)
Watchdog Enable.
Definition: cascoda_bsp_chili.c:686
dpd_flag
Definition: cascoda_interface.h:95
const char * BSP_GetPlatString(void)
Get a string that describes this device.
Definition: cascoda_bsp_chili.c:267
void BSP_SystemConfig(fsys_mhz fsys, u8_t enable_comms)
re-configures system clock frequency and comms interface
Definition: cascoda_bsp_chili.c:795
void BSP_RTCRegisterCallback(int(*callback)(void))
Registers RTC IRQ function callback.
Definition: cascoda_rtc_m2351_secure.c:373
ca_error BSP_RTCSetAlarmSeconds(u32_t seconds)
Sets RTC Alarm in seconds from current time.
Definition: cascoda_rtc_m2351_secure.c:273
void BSP_UseExternalClock(u8_t useExternalClock)
Enable or disable the usage of the external clock from the CA821x.
Definition: cascoda_bsp_chili.c:607
module_pin_led_set
Definition: cascoda_interface.h:172
@ MODULE_PIN_IRQ_OFF
irq off
Definition: cascoda_interface.h:140
@ MODULE_PIN_IRQ_FALL
irq falling edge
Definition: cascoda_interface.h:141
@ MODULE_PIN_IRQ_BOTH
irq both edges
Definition: cascoda_interface.h:143
@ MODULE_PIN_IRQ_RISE
irq rising edge
Definition: cascoda_interface.h:142
@ FSYS_EXTERNAL_CA821X
Definition: cascoda_interface.h:71
@ FSYS_12MHZ
Definition: cascoda_interface.h:64
@ FSYS_INTERNAL_HIRC
Definition: cascoda_interface.h:73
@ FSYS_INTERNAL_HIRC48
Definition: cascoda_interface.h:74
@ FSYS_24MHZ
Definition: cascoda_interface.h:66
@ FSYS_48MHZ
Definition: cascoda_interface.h:68
@ FSYS_EXTERNAL_NUMAKER
Definition: cascoda_interface.h:72
@ FSYS_64MHZ
Definition: cascoda_interface.h:69
@ FSYS_EXTERNAL_SOURCE
Definition: cascoda_interface.h:78
@ FSYS_32MHZ
Definition: cascoda_interface.h:67
@ FSYS_4MHZ
Definition: cascoda_interface.h:63
@ FSYS_16MHZ
Definition: cascoda_interface.h:65
@ SYSRESET_APROM
Systemreset normally, into application flash.
Definition: cascoda_interface.h:104
@ SYSRESET_DFU
System reset into Device Firmware Update mode.
Definition: cascoda_interface.h:105
@ MODULE_PIN_DIR_IN
input
Definition: cascoda_interface.h:112
@ MODULE_PIN_DIR_OUT
output
Definition: cascoda_interface.h:113
@ MODULE_PIN_TYPE_GENERIC
pin not attached to LED
Definition: cascoda_interface.h:133
@ MODULE_PIN_TYPE_LED
pin is attached to LED
Definition: cascoda_interface.h:134
@ P_NA
Pin/Port functionality not available.
Definition: cascoda_interface.h:148
@ MODULE_PIN_PULLUP_OFF
pull-up off
Definition: cascoda_interface.h:119
@ MODULE_PIN_PULLUP_ON
pull-up on
Definition: cascoda_interface.h:120
@ WAKEUP_DEEP_POWERDOWN
deep-power-down (DPD) with no data retention
Definition: cascoda_interface.h:86
@ WAKEUP_RTCALARM
RTC Alarm.
Definition: cascoda_interface.h:90
@ WAKEUP_SYSRESET
System Reset.
Definition: cascoda_interface.h:89
@ WAKEUP_WATCHDOG
Watchdog Timeout.
Definition: cascoda_interface.h:87
@ WAKEUP_HARDFAULT
Hardfault.
Definition: cascoda_interface.h:88
@ WAKEUP_POWERON
power-on
Definition: cascoda_interface.h:85
@ MODULE_PIN_DEBOUNCE_OFF
debounce off
Definition: cascoda_interface.h:126
@ MODULE_PIN_DEBOUNCE_ON
debounce on
Definition: cascoda_interface.h:127
@ DPD_FLAG_NO_DPD
Definition: cascoda_interface.h:96
@ DPD_FLAG_WAKEUP_DISABLED
Definition: cascoda_interface.h:98
@ DPD_FLAG_WAKEUP_ENABLED
Definition: cascoda_interface.h:97
@ LED_ON
Definition: cascoda_interface.h:173
@ LED_OFF
Definition: cascoda_interface.h:174
ca_error
Cascoda error type.
Definition: ca821x_error.h:51
Definition: cascoda_interface.h:178
u8_t USB_PRESENT
Definition: cascoda_interface.h:182
u8_t SWITCH
Definition: cascoda_interface.h:179
u8_t LED_RED
Definition: cascoda_interface.h:181
u8_t LED_GREEN
Definition: cascoda_interface.h:180
Interface Structure for RTC Date and Time.
Definition: cascoda_interface.h:192
u32_t year
Year (i.e.
Definition: cascoda_interface.h:193
u32_t sec
Seconds (0-59)
Definition: cascoda_interface.h:198
u32_t hour
Hour (0-23)
Definition: cascoda_interface.h:196
u32_t month
Month (1-12)
Definition: cascoda_interface.h:194
u32_t min
Minutes (0-59)
Definition: cascoda_interface.h:197
u32_t day
Day (1-31)
Definition: cascoda_interface.h:195
CA-821x Device reference struct.
Definition: ca821x_api.h:123
Description of the internal flash.
Definition: cascoda_flash.h:47