Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
|
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "M2351.h"
#include "cascoda-bm/cascoda_interface.h"
#include "cascoda-bm/cascoda_spi.h"
#include "cascoda-util/cascoda_tasklet.h"
#include "cascoda_chili.h"
#include "cascoda_chili_gpio.h"
#include "cascoda_secure.h"
Typedefs | |
typedef enum statusRegister1_masks | statusRegister1_masks |
Masks for individual bits in Status Register 1. More... | |
typedef enum statusRegister1_pos | statusRegister1_pos |
Bit positions for Status Register 1. More... | |
Enumerations | |
enum | statusRegister1_masks { BUSY_mask = 0x01 , WEL_mask = 0x02 , BP0_mask = 0x04 , BP1_mask = 0x08 , BP2_mask = 0x10 , TB_mask = 0x20 , SEC_mask = 0x40 , SRP0_mask = 0x80 , WEL_mask = 0x02 } |
Masks for individual bits in Status Register 1. More... | |
enum | statusRegister1_pos { BUSY_pos = 0 , WEL_pos , BP0_pos , BP1_pos , BP2_pos , TB_pos , SEC_pos , SRP0_pos , WEL_pos = 1 } |
Bit positions for Status Register 1. More... | |
Functions | |
void | BSP_SetSPIMOSIOutput (void) |
Connect MOSI port to SPI MOSI and disable pull-up. More... | |
void | BSP_SetSPIMOSITristate (void) |
Disconnect MOSI port from SPI MOSI and put to tristate with pull-up. More... | |
ca_error | W25Q80DLSNIG_WriteEnable () |
Set the Write Enable Latch bit in the Status Register to a 1. More... | |
ca_error | W25Q80DLSNIG_WriteDisable () |
Set the Write Enable Latch bit in the Status Register to a 0. More... | |
ca_error | W25Q80DLSNIG_ReadStatusRegister1 (uint8_t *statusRegister1) |
Read the 8-bit Status Register 1. More... | |
ca_error | W25Q80DLSNIG_PowerDown () |
Put the external flash chip in power down mode. More... | |
ca_error | W25Q80DLSNIG_ReleasePowerDown (void) |
Release the external flash chip from power down mode. More... | |
void | BSP_ExternalFlashInit (void) |
ca_error | BSP_ExternalFlashProgram (uint32_t aStartAddress, uint8_t aNumOfBytes, uint8_t *aTxData) |
ca_error | BSP_ExternalFlashReadData (uint32_t aStartAddress, uint8_t aNumOfBytes, uint8_t *aRxData) |
ca_error | BSP_ExternalFlashPartialErase (ExternalFlashPartialEraseType aEraseType, uint32_t aAddress) |
ca_error | BSP_ExternalFlashChipErase (void) |
ca_error | BSP_ExternalFlashGetDeviceId (uint8_t *aId) |
ca_error | BSP_ExternalFlashGetStatus (struct ExternalFlashStatus *status) |
ca_error | BSP_ExternalFlashScheduleCallback (ExternalFlashCallback aCallback, void *aContext) |
void | BSP_ExternalFlashGetInfo (struct ExternalFlashInfo *aFlashInfoOut) |
Variables | |
const struct ExternalFlashInfo | BSP_ExternalFlashInfo |
#define ADDRESS_BYTE_LENGTH 3 |
#define BLOCK_ERASE_32KB 0x52 |
#define BLOCK_ERASE_64KB 0xD8 |
#define CHIP_ERASE 0xC7 |
#define DONT_CARE_BYTE 0x00 |
#define DUMMY_BYTE 0xFF |
#define EXTERNAL_FLASH_BASE 0xB0000000 |
#define INSTRUCTION_BYTE_LENGTH 1 |
#define NUM_OF_BYTES_IN_A_PAGE 256 |
#define PAGE_PROGRAM 0x02 |
#define PAGE_PROGRAM_MAX_BYTES_ACTUAL (PAGE_PROGRAM_MAX_BYTES_THEORETICAL / 2) |
#define PAGE_PROGRAM_MAX_BYTES_THEORETICAL NUM_OF_BYTES_IN_A_PAGE |
#define PAGE_PROGRAM_MAX_TX_LEN (INSTRUCTION_BYTE_LENGTH + ADDRESS_BYTE_LENGTH + PAGE_PROGRAM_MAX_BYTES_ACTUAL) |
#define POWER_DOWN 0xB9 |
#define READ_DATA 0x03 |
#define READ_DATA_MAX_BYTES_ACTUAL PAGE_PROGRAM_MAX_BYTES_ACTUAL |
#define READ_DATA_MAX_BYTES_THEORETICAL 1048576 |
#define READ_DATA_MAX_RX_LEN PAGE_PROGRAM_MAX_TX_LEN |
#define READ_STATUS_REGISTER_1 0x05 |
#define RELEASE_POWERDOWN_ID 0xAB |
#define SECTOR_ERASE_4KB 0x20 |
#define T_BE1 800 |
#define T_BE2 1000 |
#define T_CE 6000 |
#define T_DP 4 |
#define T_PP 4 |
#define T_RES1 4 |
#define T_SE 300 |
#define WRITE_DISABLE 0x04 |
#define WRITE_ENABLE 0x06 |
typedef enum statusRegister1_masks statusRegister1_masks |
Masks for individual bits in Status Register 1.
typedef enum statusRegister1_pos statusRegister1_pos |
Bit positions for Status Register 1.
enum statusRegister1_pos |
ca_error BSP_ExternalFlashChipErase | ( | void | ) |
ca_error BSP_ExternalFlashGetDeviceId | ( | uint8_t * | aId | ) |
void BSP_ExternalFlashGetInfo | ( | struct ExternalFlashInfo * | aFlashInfoOut | ) |
ca_error BSP_ExternalFlashGetStatus | ( | struct ExternalFlashStatus * | status | ) |
void BSP_ExternalFlashInit | ( | void | ) |
ca_error BSP_ExternalFlashPartialErase | ( | ExternalFlashPartialEraseType | aEraseType, |
uint32_t | aAddress | ||
) |
ca_error BSP_ExternalFlashProgram | ( | uint32_t | aStartAddress, |
uint8_t | aNumOfBytes, | ||
uint8_t * | aTxData | ||
) |
ca_error BSP_ExternalFlashReadData | ( | uint32_t | aStartAddress, |
uint8_t | aNumOfBytes, | ||
uint8_t * | aRxData | ||
) |
ca_error BSP_ExternalFlashScheduleCallback | ( | ExternalFlashCallback | aCallback, |
void * | aContext | ||
) |
ca_error W25Q80DLSNIG_PowerDown | ( | ) |
Put the external flash chip in power down mode.
When in power down mode, the external flash chip consumes less power and will ignore all instructions except for RELEASE_POWERDOWN_ID.
CA_ERROR_SUCCESS | Success. |
CA_ERROR_BUSY | SPI is currently being used to communicate with the RF chip. |
ca_error W25Q80DLSNIG_ReadStatusRegister1 | ( | uint8_t * | statusRegister1 | ) |
Read the 8-bit Status Register 1.
(Function used internally by BSP_ExternalFlashGetStatus)
statusRegister1 | Stores the value of Status Register 1 that was read. |
CA_ERROR_SUCCESS | Success. |
CA_ERROR_BUSY | SPI is currently being used to communicate with the RF chip. |
ca_error W25Q80DLSNIG_ReleasePowerDown | ( | void | ) |
Release the external flash chip from power down mode.
This is a multi-purpose instruction, because it can also get the ID of the device at the same time.
CA_ERROR_SUCCESS | Success. |
CA_ERROR_BUSY | SPI is currently being used to communicate with the RF chip. |
ca_error W25Q80DLSNIG_WriteDisable | ( | ) |
Set the Write Enable Latch bit in the Status Register to a 0.
(Function used for testing purposes).
CA_ERROR_SUCCESS | Success. |
CA_ERROR_BUSY | SPI is currently being used to communicate with the RF chip. |
ca_error W25Q80DLSNIG_WriteEnable | ( | ) |
Set the Write Enable Latch bit in the Status Register to a 1.
Forward declarations for non-BSP functions.
The WEL bit must be set prior to every Page Program, Sector Erase, Block Erase, Chip Erase and Write Status Register instruction. The WEL bit is reset to 0 upon completion of every aforementioned instruction. (Function used internally by BSP_ExternalFlashChipErase, BSP_ExternalFlashPartialErase and BSP_ExternalFlashProgram)
CA_ERROR_SUCCESS | Success. |
CA_ERROR_BUSY | SPI is currently being used to communicate with the RF chip. |
const struct ExternalFlashInfo BSP_ExternalFlashInfo |