Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Loading...
Searching...
No Matches
cascoda_interface.h File Reference

Declaration of platform abstraction functions. More...

#include <stdbool.h>
#include <stdint.h>
#include "cascoda-bm/cascoda_bm.h"
#include "cascoda-bm/cascoda_interface_core.h"
#include "cascoda-util/cascoda_flash.h"
#include "ca821x_api.h"
#include "cascoda_chili_config.h"
Include dependency graph for cascoda_interface.h:

Go to the source code of this file.

Classes

struct  gpio_input_args
 Arguments for the BSP_ModuleRegisterGPIOInput function. More...
struct  ModuleSpecialPins
struct  RTCDateAndTime
 Interface Structure for RTC Date and Time. More...

Macros

#define WHILE_LOOP_STUCK_TIMEOUT   300000
#define MSP_DEFAULT   P_NA, P_NA, P_NA, P_NA

Typedefs

typedef enum fsys_mhz fsys_mhz
typedef enum wakeup_reason wakeup_reason
typedef enum dpd_flag dpd_flag
typedef enum sysreset_mode sysreset_mode
typedef enum module_pin_dir module_pin_dir
 Pin Type.
typedef enum module_pin_pullup module_pin_pullup
 Pin Pull-Up.
typedef enum module_pin_debounce module_pin_debounce
 Pin Debounce.
typedef enum module_pin_type module_pin_type
 Pin is LED?
typedef enum module_pin_irq module_pin_irq
 Pin Interrupt.
typedef enum module_debounce_filter_time module_debounce_filter_time
typedef enum bod_voltage_level bod_voltage_level
typedef void(* dispatch_read_t) (struct ca821x_dev *pDeviceRef)

Enumerations

enum  fsys_mhz {
  FSYS_4MHZ = 4 , FSYS_12MHZ = 12 , FSYS_16MHZ = 16 , FSYS_24MHZ = 24 ,
  FSYS_32MHZ = 32 , FSYS_48MHZ = 48 , FSYS_64MHZ = 64 , FSYS_EXTERNAL_CA821X = FSYS_4MHZ ,
  FSYS_EXTERNAL_NUMAKER = FSYS_12MHZ , FSYS_INTERNAL_HIRC = FSYS_12MHZ , FSYS_INTERNAL_HIRC48 = FSYS_48MHZ , FSYS_EXTERNAL_SOURCE = FSYS_EXTERNAL_CA821X
}
enum  wakeup_reason {
  WAKEUP_POWERON = 0 , WAKEUP_DEEP_POWERDOWN = 1 , WAKEUP_WATCHDOG = 2 , WAKEUP_HARDFAULT = 3 ,
  WAKEUP_SYSRESET = 4 , WAKEUP_RTCALARM = 5
}
enum  dpd_flag { DPD_FLAG_NO_DPD = 0 , DPD_FLAG_WAKEUP_ENABLED = 1 , DPD_FLAG_WAKEUP_DISABLED = 2 }
enum  sysreset_mode { SYSRESET_APROM = 0 , SYSRESET_DFU = 1 }
enum  module_pin_dir { MODULE_PIN_DIR_IN = 0 , MODULE_PIN_DIR_OUT = 1 }
 Pin Type. More...
enum  module_pin_pullup { MODULE_PIN_PULLUP_OFF = 0 , MODULE_PIN_PULLUP_ON = 1 }
 Pin Pull-Up. More...
enum  module_pin_debounce { MODULE_PIN_DEBOUNCE_OFF = 0 , MODULE_PIN_DEBOUNCE_ON = 1 }
 Pin Debounce. More...
enum  module_pin_type { MODULE_PIN_TYPE_GENERIC = 0 , MODULE_PIN_TYPE_LED = 1 }
 Pin is LED? More...
enum  module_pin_irq { MODULE_PIN_IRQ_OFF = 0 , MODULE_PIN_IRQ_FALL = 1 , MODULE_PIN_IRQ_RISE = 2 , MODULE_PIN_IRQ_BOTH = 3 }
 Pin Interrupt. More...
enum  module_debounce_filter_time {
  MODULE_T_FILTER_100U = 0 , MODULE_T_FILTER_200U = 1 , MODULE_T_FILTER_400U = 2 , MODULE_T_FILTER_800U = 3 ,
  MODULE_T_FILTER_1P6M = 4 , MODULE_T_FILTER_3P2M = 5 , MODULE_T_FILTER_6P4M = 6 , MODULE_T_FILTER_13M = 7 ,
  MODULE_T_FILTER_26M = 8 , MODULE_T_FILTER_51M = 9 , MODULE_T_FILTER_100M = 10 , MODULE_T_FILTER_200M = 11 ,
  MODULE_T_FILTER_400M = 12 , MODULE_T_FILTER_800M = 13 , MODULE_T_FILTER_1P6S = 14 , MODULE_T_FILTER_3P2S = 15
}
enum  module_pin_not_available { P_NA = 255 }
enum  bod_voltage_level {
  BOD_VLEVEL_3_0V = 0 , BOD_VLEVEL_2_8V = 1 , BOD_VLEVEL_2_6V = 2 , BOD_VLEVEL_2_4V = 3 ,
  BOD_VLEVEL_2_2V = 4 , BOD_VLEVEL_2_0V = 5
}
enum  module_pin_led_set { LED_ON = 0 , LED_OFF = 1 }

Functions

void BSP_EnableSerialIRQ (void)
 Enable the serial (usb/uart) irq.
void BSP_DisableSerialIRQ (void)
 Disable the serial (usb/uart) irq.
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.
void BSP_SetPowerDown (void)
 Set flag that system has started power-down sequence.
void BSP_Initialise (struct ca821x_dev *pDeviceRef)
 Initialise the system for a given ca821x_dev.
void BSP_UseExternalClock (u8_t useExternalClock)
 Enable or disable the usage of the external clock from the CA821x.
struct ModuleSpecialPins BSP_GetModuleSpecialPins (void)
 Get the struct of special pins for the platform.
ca_error BSP_ModuleRegisterGPIOInput (struct gpio_input_args *args)
 Registers GPIO Input Functionality for Module Pin.
ca_error BSP_ModuleRegisterGPIOOutput (u8_t mpin, module_pin_type isled)
 Registers GPIO Output Functionality for Module Pin.
ca_error BSP_ModuleRegisterGPIOOutputOD (u8_t mpin, module_pin_type isled)
 Registers GPIO Open Drain Output Functionality for Module Pin.
ca_error BSP_ModuleRegisterGPIOSharedInputOutputOD (struct gpio_input_args *args, module_pin_type isled)
 Registers GPIO Input AND Open Drain Output Functionality for Module Pin.
ca_error BSP_ModuleDeregisterGPIOPin (u8_t mpin)
 Unregisters GPIO Functionality for Module Pin to Default Settings.
u8_t BSP_ModuleIsGPIOPinRegistered (u8_t mpin)
 Checks if a Module Pin is already registered / used.
ca_error BSP_ModuleSetGPIOPin (u8_t mpin, u8_t val)
 Sets Module Pin GPIO Output Value.
ca_error BSP_ModuleSenseGPIOPin (u8_t mpin, u8_t *val)
 Senses GPIO Input Value of Module Pin.
ca_error BSP_ModuleSenseGPIOPinOutput (u8_t mpin, u8_t *val)
 Senses GPIO Output Value of Module Pin.
ca_error BSP_ModuleSetGPIOOutputPermanent (u8_t mpin)
 Sets Module Pin GPIO Output as permanently driven (don't tristate in Power-Down).
ca_error BSP_ModuleReadVoltsPin (u8_t mpin, u32_t *val)
 Reads ADC Conversion Value on Module Pin.
ca_error BSP_ModuleSetPBDebounceFilterTime (module_debounce_filter_time time, bool keep_permanent)
 Sets Debounce Filter Time in Sleep Mode for Port PB.
void BSP_SystemReset (sysreset_mode resetMode)
 *OPTIONAL Function Declarations for cascoda_bsp_.c
void BSP_ChipReset ()
 Reset the whole chip.
void BSP_ResetOnLoopStuck (uint32_t start_time)
 Call BSP_SystemReset() if stuck in a while loop for too long.
ca_error BSP_SetBootMode (sysreset_mode bootMode)
 Set the default boot mode for the device.
u64_t BSP_GetUniqueId (void)
 Get a 64-bit ID that is unique to this device.
const char * BSP_GetPlatString (void)
 Get a string that describes this device.
u8_t BSP_GetChargeStat (void)
 Get Microchip MCP73831 Charge Status.
u8_t BSP_GetVBUSConnected (void)
 Get USB VBUS status (connected/not connected).
i32_t BSP_GetTemperature (void)
 Measure and Read Temperature Value.
u32_t BSP_ADCGetVolts (void)
 Measure and Read Battery Volts Value from ADC.
wakeup_reason BSP_GetWakeupReason (void)
 Reason MCU has woken up after reset.
void BSP_WatchdogEnable (u32_t timeout_ms)
 Watchdog Enable.
void BSP_WatchdogReset (void)
 Watchdog Reset and Restart.
void BSP_WatchdogDisable (void)
 Watchdog Disable.
u8_t BSP_IsWatchdogTriggered (void)
 Checks if the watchdog has been triggered, clears the warning if so.
void BSP_EnableUSB (void)
 Enable the USB if connected.
void BSP_DisableUSB (void)
 Disable the USB.
u8_t BSP_IsUSBPresent (void)
 Is the USB connected?
fsys_mhz BSP_GetSystemFrequency (void)
 Returns the system frequency.
void BSP_SystemConfig (fsys_mhz fsys, u8_t enable_comms)
 re-configures system clock frequency and comms interface
void BSP_GetFlashInfo (struct ca_flash_info *aFlashInfoOut)
 Get the flashinfo struct for the current platform.
ca_error BSP_FlashWriteInitial (u32_t startaddr, void *data, u32_t datasize)
 Writes Dataflash Memory, relies on Memory erased.
ca_error BSP_FlashErase (u32_t startaddr)
 Erases a Dataflash Memory page (All words in page set to 0xFFFFFFFF).
ca_error BSP_FlashRead (u32_t startaddr, u32_t *data, u32_t datasize)
 Reads Flash Memory.
void BSP_FlashLock (void)
 Prevent ICP access to Flash.
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.
void BSP_RTCInitialise (void)
 Initialises RTC.
ca_error BSP_RTCSetAlarmSeconds (u32_t seconds)
 Sets RTC Alarm in seconds from current time.
void BSP_RTCDisableAlarm (void)
 Disables RTC Alarm.
ca_error BSP_RTCSetDateAndTime (struct RTCDateAndTime dateandtime)
 Sets RTC Date+Time.
void BSP_RTCGetDateAndTime (struct RTCDateAndTime *dateandtime)
 Gets RTC Date+Time.
void BSP_RTCConvertSecondsToDateAndTime (i64_t seconds, struct RTCDateAndTime *dateandtime)
 Converts Unix Time seconds to RTC Date+Time.
i64_t BSP_RTCConvertDateAndTimeToSeconds (const struct RTCDateAndTime *dateandtime)
 Converts RTC Date+Time to Unix Time seconds.
void BSP_RTCRegisterCallback (int(*callback)(void))
 Registers RTC IRQ function callback.
void BSP_BODEnable (void)
 Enable BOD.
void BSP_BODDisable (void)
 Disable BOD.
void BSP_BODRegisterCallback (int(*callback)(void))
 Register BOD interrupt function callback.
void BSP_BODEnableLPM (bool enable)
 Enable/disable BOD low power mode (lpm).
ca_error BSP_BODSetVoltageLevel (bod_voltage_level vlevel)
 Set BOD trigger voltage level.

Detailed Description

Declaration of platform abstraction functions.