Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
flash_test_main.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cascoda-bm/cascoda_evbme.h"
#include "cascoda-bm/cascoda_interface.h"
#include "cascoda-bm/cascoda_sensorif.h"
#include "cascoda-bm/cascoda_serial.h"
#include "cascoda-bm/cascoda_spi.h"
#include "cascoda-bm/cascoda_types.h"
#include "cascoda-bm/cascoda_wait.h"
#include "cascoda-util/cascoda_tasklet.h"
#include "cascoda-util/cascoda_time.h"
#include "ca821x_api.h"
#include "cascoda-bm/test15_4_evbme.h"
Include dependency graph for flash_test_main.c:

Classes

struct  read_data_helper_args
 
struct  page_program_helper_args
 

Macros

#define TEST_MSDULENGTH   (40)
 
#define TEST_MSDUHANDLE   (0xAA)
 
#define TEST_MSDU
 
#define TEST_PANID   0x5C, 0xCA
 
#define TEST_DSTADDR   0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88
 
#define NUMBER_OF_BYTES_IN_A_PAGE   256
 
#define NUMBER_OF_BYTES_IN_HALF_A_PAGE   (NUMBER_OF_BYTES_IN_A_PAGE / 2)
 
#define NUMBER_OF_PAGES_TOTAL   4096
 
#define NUMBER_OF_HALF_PAGES_TOTAL   (NUMBER_OF_PAGES_TOTAL * 2)
 
#define NUMBER_OF_PAGES_IN_A_SECTOR   16
 
#define NUMBER_OF_HALF_PAGES_IN_A_SECTOR   (NUMBER_OF_PAGES_IN_A_SECTOR * 2)
 
#define NUMBER_OF_PAGES_IN_A_32KB_BLOCK   128
 
#define NUMBER_OF_HALF_PAGES_IN_A_32KB_BLOCK   (NUMBER_OF_PAGES_IN_A_32KB_BLOCK * 2)
 
#define NUMBER_OF_PAGES_IN_A_64KB_BLOCK   (NUMBER_OF_PAGES_IN_A_32KB_BLOCK * 2)
 
#define NUMBER_OF_HALF_PAGES_IN_A_64KB_BLOCK   (NUMBER_OF_PAGES_IN_A_64KB_BLOCK * 2)
 

Typedefs

typedef struct read_data_helper_args read_data_helper_args
 
typedef struct page_program_helper_args page_program_helper_args
 
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  FLASH_nextState {
  FLASH_GET_DEVICE_ID , FLASH_READ_STATUS_REG1 , FLASH_WRITE_ENABLE_DISABLE , FLASH_CHIP_ERASE_AND_READ_DATA ,
  FLASH_PAGE_PROGRAM_AND_ERASE_SECTOR , FLASH_PAGE_PROGRAM_AND_ERASE_BLOCK32K , FLASH_PAGE_PROGRAM_AND_ERASE_BLOCK64K , FLASH_POWERDOWN_AND_RELEASE ,
  FLASH_PROGRAM_READ_AND_ERASE_UNDER_STRESS , FLASH_PROGRAM_AND_OVERWRITE , END
}
 
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

ca_error W25Q80DLSNIG_WriteEnable ()
 Forward declarations for non-BSP functions. More...
 
ca_error W25Q80DLSNIG_WriteDisable ()
 Set the Write Enable Latch bit in the Status Register to a 0. More...
 
ca_error W25Q80DLSNIG_PowerDown ()
 Put the external flash chip in power down mode. More...
 
ca_error W25Q80DLSNIG_ReleasePowerDown ()
 Release the external flash chip from power down mode. More...
 
ca_error W25Q80DLSNIG_ReadStatusRegister1 (uint8_t *statusRegister1)
 Read the 8-bit Status Register 1. More...
 
int test15_4_serial_dispatch (uint8_t *buf, size_t len, struct ca821x_dev *pDeviceRef)
 
ca_error test_GetDeviceId ()
 
ca_error test_ReadStatusRegister1 ()
 
ca_error test_WriteEnableAndDisable (void *aContext)
 
ca_error test_ChipEraseAndReadData (void *aContext)
 
ca_error test_PageProgramAndEraseSector (void *aContext)
 
ca_error test_PageProgramAndEraseBlock32k (void *aContext)
 
ca_error test_PageProgramAndEraseBlock64k (void *aContext)
 
ca_error test_PowerDownAndReleasePowerDown (void *aContext)
 
ca_error test_OverWriteData (void *aContext)
 
ca_error handle_tests ()
 
int main (void)
 Main Program Endless Loop. More...
 

Variables

ca_tasklet testTasklet
 
struct ca821x_dev dev
 

Macro Definition Documentation

◆ NUMBER_OF_BYTES_IN_A_PAGE

#define NUMBER_OF_BYTES_IN_A_PAGE   256

◆ NUMBER_OF_BYTES_IN_HALF_A_PAGE

#define NUMBER_OF_BYTES_IN_HALF_A_PAGE   (NUMBER_OF_BYTES_IN_A_PAGE / 2)

◆ NUMBER_OF_HALF_PAGES_IN_A_32KB_BLOCK

#define NUMBER_OF_HALF_PAGES_IN_A_32KB_BLOCK   (NUMBER_OF_PAGES_IN_A_32KB_BLOCK * 2)

◆ NUMBER_OF_HALF_PAGES_IN_A_64KB_BLOCK

#define NUMBER_OF_HALF_PAGES_IN_A_64KB_BLOCK   (NUMBER_OF_PAGES_IN_A_64KB_BLOCK * 2)

◆ NUMBER_OF_HALF_PAGES_IN_A_SECTOR

#define NUMBER_OF_HALF_PAGES_IN_A_SECTOR   (NUMBER_OF_PAGES_IN_A_SECTOR * 2)

◆ NUMBER_OF_HALF_PAGES_TOTAL

#define NUMBER_OF_HALF_PAGES_TOTAL   (NUMBER_OF_PAGES_TOTAL * 2)

◆ NUMBER_OF_PAGES_IN_A_32KB_BLOCK

#define NUMBER_OF_PAGES_IN_A_32KB_BLOCK   128

◆ NUMBER_OF_PAGES_IN_A_64KB_BLOCK

#define NUMBER_OF_PAGES_IN_A_64KB_BLOCK   (NUMBER_OF_PAGES_IN_A_32KB_BLOCK * 2)

◆ NUMBER_OF_PAGES_IN_A_SECTOR

#define NUMBER_OF_PAGES_IN_A_SECTOR   16

◆ NUMBER_OF_PAGES_TOTAL

#define NUMBER_OF_PAGES_TOTAL   4096

◆ TEST_DSTADDR

#define TEST_DSTADDR   0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88

◆ TEST_MSDU

#define TEST_MSDU
Value:
0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, \
0xEF, 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, \
0xAD, 0xBE, 0xEF

◆ TEST_MSDUHANDLE

#define TEST_MSDUHANDLE   (0xAA)

◆ TEST_MSDULENGTH

#define TEST_MSDULENGTH   (40)

◆ TEST_PANID

#define TEST_PANID   0x5C, 0xCA

Typedef Documentation

◆ page_program_helper_args

◆ read_data_helper_args

◆ statusRegister1_masks

Masks for individual bits in Status Register 1.

◆ statusRegister1_pos

Bit positions for Status Register 1.

Enumeration Type Documentation

◆ FLASH_nextState

Enumerator
FLASH_GET_DEVICE_ID 
FLASH_READ_STATUS_REG1 
FLASH_WRITE_ENABLE_DISABLE 
FLASH_CHIP_ERASE_AND_READ_DATA 
FLASH_PAGE_PROGRAM_AND_ERASE_SECTOR 
FLASH_PAGE_PROGRAM_AND_ERASE_BLOCK32K 
FLASH_PAGE_PROGRAM_AND_ERASE_BLOCK64K 
FLASH_POWERDOWN_AND_RELEASE 
FLASH_PROGRAM_READ_AND_ERASE_UNDER_STRESS 
FLASH_PROGRAM_AND_OVERWRITE 
END 

◆ statusRegister1_masks

Masks for individual bits in Status Register 1.

Enumerator
BUSY_mask 

S0.

WEL_mask 

S1.

BP0_mask 

S2.

BP1_mask 

S3.

BP2_mask 

S4.

TB_mask 

S5.

SEC_mask 

S6.

SRP0_mask 

S7.

WEL_mask 

S1 mask.

◆ statusRegister1_pos

Bit positions for Status Register 1.

Enumerator
BUSY_pos 

S0.

WEL_pos 

S1.

BP0_pos 

S2.

BP1_pos 

S3.

BP2_pos 

S4.

TB_pos 

S5.

SEC_pos 

S6.

SRP0_pos 

S7.

WEL_pos 

S1 position.

Function Documentation

◆ handle_tests()

ca_error handle_tests ( )

◆ main()

int main ( void  )

Main Program Endless Loop.

Returns
Does not return

◆ test15_4_serial_dispatch()

int test15_4_serial_dispatch ( uint8_t *  buf,
size_t  len,
struct ca821x_dev pDeviceRef 
)

◆ test_ChipEraseAndReadData()

ca_error test_ChipEraseAndReadData ( void *  aContext)

◆ test_GetDeviceId()

ca_error test_GetDeviceId ( )

◆ test_OverWriteData()

ca_error test_OverWriteData ( void *  aContext)

◆ test_PageProgramAndEraseBlock32k()

ca_error test_PageProgramAndEraseBlock32k ( void *  aContext)

◆ test_PageProgramAndEraseBlock64k()

ca_error test_PageProgramAndEraseBlock64k ( void *  aContext)

◆ test_PageProgramAndEraseSector()

ca_error test_PageProgramAndEraseSector ( void *  aContext)

◆ test_PowerDownAndReleasePowerDown()

ca_error test_PowerDownAndReleasePowerDown ( void *  aContext)

◆ test_ReadStatusRegister1()

ca_error test_ReadStatusRegister1 ( )

◆ test_WriteEnableAndDisable()

ca_error test_WriteEnableAndDisable ( void *  aContext)

◆ W25Q80DLSNIG_PowerDown()

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.

Returns
Status of the command.
Return values
CA_ERROR_SUCCESSSuccess.
CA_ERROR_BUSYSPI is currently being used to communicate with the RF chip.

◆ W25Q80DLSNIG_ReadStatusRegister1()

ca_error W25Q80DLSNIG_ReadStatusRegister1 ( uint8_t *  statusRegister1)

Read the 8-bit Status Register 1.

(Function used internally by BSP_ExternalFlashGetStatus)

Parameters
statusRegister1Stores the value of Status Register 1 that was read.
Returns
Status of the command.
Return values
CA_ERROR_SUCCESSSuccess.
CA_ERROR_BUSYSPI is currently being used to communicate with the RF chip.

◆ W25Q80DLSNIG_ReleasePowerDown()

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.

Returns
Status of the command.
Return values
CA_ERROR_SUCCESSSuccess.
CA_ERROR_BUSYSPI is currently being used to communicate with the RF chip.

◆ W25Q80DLSNIG_WriteDisable()

ca_error W25Q80DLSNIG_WriteDisable ( )

Set the Write Enable Latch bit in the Status Register to a 0.

(Function used for testing purposes).

Returns
Status of the command.
Return values
CA_ERROR_SUCCESSSuccess.
CA_ERROR_BUSYSPI is currently being used to communicate with the RF chip.

◆ W25Q80DLSNIG_WriteEnable()

ca_error W25Q80DLSNIG_WriteEnable ( )

Forward declarations for non-BSP functions.

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)

Returns
Status of the command.
Return values
CA_ERROR_SUCCESSSuccess.
CA_ERROR_BUSYSPI is currently being used to communicate with the RF chip.

Variable Documentation

◆ dev

struct ca821x_dev dev

◆ testTasklet

ca_tasklet testTasklet