Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
|
#include <stdio.h>
#include "M2351.h"
#include "eadc.h"
#include "fmc.h"
#include "gpio.h"
#include "spi.h"
#include "sys.h"
#include "timer.h"
#include "usbd.h"
#include "cascoda_chili.h"
#include "cascoda-bm/cascoda_interface.h"
#include "cascoda-bm/cascoda_types.h"
#include "cascoda-bm/cascoda_usbhid.h"
#include "cascoda_chili_config.h"
#include "cascoda_chili_gpio.h"
#include "cascoda_chili_usb.h"
#include "cascoda_secure.h"
Macros | |
#define | CLKCFG_ENPLL 0x01 |
#define | CLKCFG_ENHXT 0x02 |
#define | CLKCFG_ENHIRC 0x04 |
#define | CLKCFG_ENHIRC48 0x08 |
#define | EP0_MAX_PKT_SIZE HID_CTRL_MAX_SIZE |
#define | EP1_MAX_PKT_SIZE EP0_MAX_PKT_SIZE |
#define | EP2_MAX_PKT_SIZE HID_FRAGMENT_SIZE |
#define | EP3_MAX_PKT_SIZE HID_FRAGMENT_SIZE |
#define | SETUP_BUF_BASE 0 |
#define | SETUP_BUF_LEN 8 |
#define | EP0_BUF_BASE (SETUP_BUF_BASE + SETUP_BUF_LEN) |
#define | EP0_BUF_LEN EP0_MAX_PKT_SIZE |
#define | EP1_BUF_BASE (SETUP_BUF_BASE + SETUP_BUF_LEN) |
#define | EP1_BUF_LEN EP1_MAX_PKT_SIZE |
#define | EP2_BUF_BASE (EP1_BUF_BASE + EP1_BUF_LEN) |
#define | EP2_BUF_LEN EP2_MAX_PKT_SIZE |
#define | EP3_BUF_BASE (EP2_BUF_BASE + EP2_BUF_LEN) |
#define | EP3_BUF_LEN EP3_MAX_PKT_SIZE |
#define | TBUFFS (8) /* Number of HID transmit buffers */ |
#define | RBUFFS (8) /* Number of HID receive buffers */ |
Functions | |
__NONSECURE_ENTRY ca_error | BSP_SetBootMode (sysreset_mode bootMode) |
Set the default boot mode for the device. More... | |
__NONSECURE_ENTRY void | CHILI_InitADC (u32_t reference) |
Initialise ADC peripheral. More... | |
__NONSECURE_ENTRY void | CHILI_DeinitADC () |
Deinitialise ADC peripheral. More... | |
__NONSECURE_ENTRY void | CHILI_GPIOInitClock () |
Initialise GPIO peripheral clock. More... | |
__NONSECURE_ENTRY void | CHILI_SetClockExternalCFGXT1 (u8_t clk_external) |
Configure CFGXT1 bit for HXT mode in CONFIG0. More... | |
u8_t | CHILI_GetClockConfigMask (fsys_mhz fsys, u8_t enable_comms) |
System Clock. More... | |
__NONSECURE_ENTRY ca_error | CHILI_ClockInit (fsys_mhz fsys, u8_t enable_comms) |
Select System Clocks depending on Power Source. More... | |
__NONSECURE_ENTRY void | CHILI_SetSysTickFreq (uint32_t freqHz) |
Set the SysTick frequency in Hz. More... | |
__NONSECURE_ENTRY void | CHILI_CompleteClockInit (fsys_mhz fsys, u8_t enable_comms) |
Completes Clock (Re-)Initialisation. More... | |
__NONSECURE_ENTRY void | CHILI_EnableIntOscCal (void) |
Enable Internal Oscillator Calibration. More... | |
__NONSECURE_ENTRY void | CHILI_DisableIntOscCal (void) |
Disable Internal Oscillator Calibration. More... | |
__NONSECURE_ENTRY void | CHILI_TimersInit (void) |
(Re-)Initialise System Timers More... | |
__NONSECURE_ENTRY void | CHILI_PDMAInit (void) |
Initialise PDMA. More... | |
__NONSECURE_ENTRY void | CHILI_ReInitSetTimerPriority () |
Initialise Timer IRQ priorities. More... | |
int32_t | SH_Return (int32_t n32In_R0, int32_t n32In_R1, int32_t *pn32Out_R0) |
__NONSECURE_ENTRY uint32_t | HardFault_Handler (uint32_t lr, uint32_t msp, uint32_t psp) |
__NONSECURE_ENTRY void | ProcessHardFault () |
__NONSECURE_ENTRY void | CHILI_CRYPTOEnableClock (void) |
Enable CRYPTO Module clock. More... | |
__NONSECURE_ENTRY void | CHILI_CRYPTODisableClock (void) |
Disable CRYPTO Module clock. More... | |
__NONSECURE_ENTRY void | CHILI_ModuleSetMFP (enPortnum portnum, u8_t portbit, u8_t func) |
Sets MFP Functionality. More... | |
__NONSECURE_ENTRY void | CHILI_EnableTemperatureSensor () |
Enable internal temperature sensor. More... | |
__NONSECURE_ENTRY void | CHILI_DisableTemperatureSensor () |
Disable internal temperature sensor. More... | |
__NONSECURE_ENTRY void | CHILI_PowerDownSelectClock (u8_t use_timer0) |
Configure clock for power down. More... | |
__NONSECURE_ENTRY u32_t | CHILI_PowerDownSecure (u32_t sleeptime_ms, u8_t use_timer0, dpd_flag dpd) |
Process all of the secure-only power down routines. More... | |
__NONSECURE_ENTRY void | CHILI_SetWakeup (u8_t new_wakeup) |
Set wake up state. More... | |
__NONSECURE_ENTRY u8_t | CHILI_GetWakeup () |
Should the Chili wake up? More... | |
__NONSECURE_ENTRY void | CHILI_SetAsleep (u8_t new_asleep) |
Set asleep state. More... | |
__NONSECURE_ENTRY u8_t | CHILI_GetAsleep () |
Is chili currently asleep? More... | |
__NONSECURE_ENTRY void | CHILI_SetGPIOInt (u8_t new_gpioint) |
Set gpio interrrupt occured during power-down sequence flag. More... | |
__NONSECURE_ENTRY u8_t | CHILI_GetGPIOInt () |
Has gpio interrupt occured during power-down sequence? More... | |
__NONSECURE_ENTRY void | CHILI_SetPowerDown (u8_t new_powerdown) |
Set power-down flag. More... | |
__NONSECURE_ENTRY u8_t | CHILI_GetPowerDown (void) |
Get power-down flag (device is powering down) ? More... | |
__NONSECURE_ENTRY void | CHILI_WaitForSystemStable (void) |
Wait until system is stable after potential usb plug-in. More... | |
__NONSECURE_ENTRY void | BSP_WaitUs (u32_t us) |
Wait for specified Time in Microseconds (max. More... | |
__NONSECURE_ENTRY void | CHILI_EnableTRNGClk (void) |
Enable the TRNG Module Clock. More... | |
__NONSECURE_ENTRY void | CHILI_DisableTRNGClk (void) |
Disable the TRNG Module Clock. More... | |
#define CLKCFG_ENHIRC 0x04 |
#define CLKCFG_ENHIRC48 0x08 |
#define CLKCFG_ENHXT 0x02 |
#define CLKCFG_ENPLL 0x01 |
#define EP0_BUF_BASE (SETUP_BUF_BASE + SETUP_BUF_LEN) |
#define EP0_BUF_LEN EP0_MAX_PKT_SIZE |
#define EP0_MAX_PKT_SIZE HID_CTRL_MAX_SIZE |
#define EP1_BUF_BASE (SETUP_BUF_BASE + SETUP_BUF_LEN) |
#define EP1_BUF_LEN EP1_MAX_PKT_SIZE |
#define EP1_MAX_PKT_SIZE EP0_MAX_PKT_SIZE |
#define EP2_BUF_BASE (EP1_BUF_BASE + EP1_BUF_LEN) |
#define EP2_BUF_LEN EP2_MAX_PKT_SIZE |
#define EP2_MAX_PKT_SIZE HID_FRAGMENT_SIZE |
#define EP3_BUF_BASE (EP2_BUF_BASE + EP2_BUF_LEN) |
#define EP3_BUF_LEN EP3_MAX_PKT_SIZE |
#define EP3_MAX_PKT_SIZE HID_FRAGMENT_SIZE |
#define RBUFFS (8) /* Number of HID receive buffers */ |
#define SETUP_BUF_BASE 0 |
#define SETUP_BUF_LEN 8 |
#define TBUFFS (8) /* Number of HID transmit buffers */ |
Select System Clocks depending on Power Source.
Completes Clock (Re-)Initialisation.
__NONSECURE_ENTRY void CHILI_CRYPTODisableClock | ( | void | ) |
Disable CRYPTO Module clock.
__NONSECURE_ENTRY void CHILI_CRYPTOEnableClock | ( | void | ) |
Enable CRYPTO Module clock.
__NONSECURE_ENTRY void CHILI_DeinitADC | ( | ) |
Deinitialise ADC peripheral.
__NONSECURE_ENTRY void CHILI_DisableIntOscCal | ( | void | ) |
Disable Internal Oscillator Calibration.
__NONSECURE_ENTRY void CHILI_DisableTemperatureSensor | ( | ) |
Disable internal temperature sensor.
__NONSECURE_ENTRY void CHILI_DisableTRNGClk | ( | void | ) |
Disable the TRNG Module Clock.
__NONSECURE_ENTRY void CHILI_EnableIntOscCal | ( | void | ) |
Enable Internal Oscillator Calibration.
__NONSECURE_ENTRY void CHILI_EnableTemperatureSensor | ( | ) |
Enable internal temperature sensor.
__NONSECURE_ENTRY void CHILI_EnableTRNGClk | ( | void | ) |
Enable the TRNG Module Clock.
__NONSECURE_ENTRY u8_t CHILI_GetAsleep | ( | ) |
Is chili currently asleep?
__NONSECURE_ENTRY u8_t CHILI_GetGPIOInt | ( | ) |
Has gpio interrupt occured during power-down sequence?
__NONSECURE_ENTRY u8_t CHILI_GetPowerDown | ( | void | ) |
Get power-down flag (device is powering down) ?
__NONSECURE_ENTRY u8_t CHILI_GetWakeup | ( | ) |
Should the Chili wake up?
__NONSECURE_ENTRY void CHILI_GPIOInitClock | ( | ) |
Initialise GPIO peripheral clock.
__NONSECURE_ENTRY void CHILI_InitADC | ( | u32_t | reference | ) |
Initialise ADC peripheral.
Sets MFP Functionality.
portnum | - returned port number |
portbit | - returned port b |
func | - function to set the pin to |
__NONSECURE_ENTRY void CHILI_PDMAInit | ( | void | ) |
Initialise PDMA.
Process all of the secure-only power down routines.
__NONSECURE_ENTRY void CHILI_PowerDownSelectClock | ( | u8_t | use_timer0 | ) |
Configure clock for power down.
__NONSECURE_ENTRY void CHILI_ReInitSetTimerPriority | ( | ) |
Initialise Timer IRQ priorities.
__NONSECURE_ENTRY void CHILI_SetAsleep | ( | u8_t | new_asleep | ) |
Set asleep state.
__NONSECURE_ENTRY void CHILI_SetClockExternalCFGXT1 | ( | u8_t | clk_external | ) |
Configure CFGXT1 bit for HXT mode in CONFIG0.
This isn't specifically related to dataflash, but in order to set the clock on the M2351, the config is loaded into the flash.
clk_external | - 1: external clock input on HXT, 0: HXT is crystal osc. |
__NONSECURE_ENTRY void CHILI_SetGPIOInt | ( | u8_t | new_gpioint | ) |
Set gpio interrrupt occured during power-down sequence flag.
__NONSECURE_ENTRY void CHILI_SetPowerDown | ( | u8_t | new_powerdown | ) |
Set power-down flag.
__NONSECURE_ENTRY void CHILI_SetSysTickFreq | ( | uint32_t | freqHz | ) |
Set the SysTick frequency in Hz.
freqHz | Frequency of the system tick in Hz, or 0 to disable |
__NONSECURE_ENTRY void CHILI_SetWakeup | ( | u8_t | new_wakeup | ) |
Set wake up state.
__NONSECURE_ENTRY void CHILI_TimersInit | ( | void | ) |
(Re-)Initialise System Timers
__NONSECURE_ENTRY void CHILI_WaitForSystemStable | ( | void | ) |
Wait until system is stable after potential usb plug-in.
__NONSECURE_ENTRY uint32_t HardFault_Handler | ( | uint32_t | lr, |
uint32_t | msp, | ||
uint32_t | psp | ||
) |
__NONSECURE_ENTRY void ProcessHardFault | ( | void | ) |
int32_t SH_Return | ( | int32_t | n32In_R0, |
int32_t | n32In_R1, | ||
int32_t * | pn32Out_R0 | ||
) |