BlueNRG-MS pack for STM32CubeMX: includes/bluenrg_utils.h File Reference

STM32CubeMX BlueNRG-MS

BlueNRG-MS pack for STM32CubeMX  V4.4.0
The BlueNRG-MS pack is an additional software for STM32CubeMX.
bluenrg_utils.h File Reference
#include "bluenrg_types.h"

Go to the source code of this file.

Data Structures

struct  IFR_config2_TypeDef
 

Macros

#define FROM_US_TO_SYS_TIME(us)   ((uint16_t)(us/2.4414)+1)
 
#define FROM_SYS_TIME_TO_US(sys)   ((uint16_t)(sys*2.4414))
 
#define BCD_TO_INT(bcd)   ((bcd & 0xF) + ((bcd & 0xF0) >> 4)*10)
 
#define INT_TO_BCD(n)   ((((uint8_t)n/10)<<4) + (uint8_t)n%10)
 
#define BLE_UTIL_SUCCESS   0
 
#define BLE_UTIL_UNSUPPORTED_VERSION   1
 
#define BLE_UTIL_WRONG_IMAGE_SIZE   2
 
#define BLE_UTIL_ACI_ERROR   3
 
#define BLE_UTIL_CRC_ERROR   4
 
#define BLE_UTIL_PARSE_ERROR   5
 
#define BLE_UTIL_WRONG_VERIFY   6
 

Typedefs

struct {
   uint8_t   cold_ana_act_config_table [64]
 
   uint8_t   hot_ana_config_table [64]
 
   uint8_t   stack_mode
 
   uint8_t   gpio_config
 
   uint8_t   rsrvd1 [2]
 
   uint32_t   rsrvd2 [3]
 
   uint32_t   max_conn_event_time
 
   uint32_t   ls_crystal_period
 
   uint32_t   ls_crystal_freq
 
   uint16_t   slave_sca_ppm
 
   uint8_t   master_sca
 
   uint8_t   rsrvd3
 
   uint16_t   hs_startup_time
 
   uint8_t   rsrvd4 [2]
 
   uint32_t   uid
 
   uint8_t   rsrvd5
 
   uint8_t   year
 
   uint8_t   month
 
   uint8_t   day
 
   uint32_t   unused [5]
 
IFR_config_TypeDef
 

Functions

int program_device (const uint8_t *fw_image, uint32_t fw_size)
 Flash a new firmware using internal bootloader. More...
 
int read_IFR (uint8_t data[192])
 Read raw data from IFR (3 64-bytes blocks). More...
 
uint8_t verify_IFR (const IFR_config_TypeDef *ifr_data)
 Verify raw data from IFR (3 64-bytes blocks). More...
 
int program_IFR (const IFR_config_TypeDef *ifr_image)
 Program raw data to IFR (3 64-bytes blocks). More...
 
void parse_IFR_data_config (const uint8_t data[64], IFR_config2_TypeDef *IFR_config)
 Parse IFR raw data. More...
 
int IFR_validate (IFR_config2_TypeDef *IFR_config)
 Check for the correctness of parsed data. More...
 
void change_IFR_data_config (IFR_config2_TypeDef *IFR_config, uint8_t data[64])
 Modify IFR data. (Last 64-bytes block). More...
 
uint8_t getBlueNRGVersion (uint8_t *hwVersion, uint16_t *fwVersion)
 Get BlueNRG hardware and firmware version. More...
 
uint8_t getBlueNRGUpdaterVersion (uint8_t *version)
 Get BlueNRG updater version. More...
 
uint8_t isHWBootloader_Patched (void)
 Verifies if the bootloader is patched or not. This function shall be used to fix a bug on the HW bootloader related to the 32 MHz external crystal oscillator. More...
 

Variables

const IFR_config_TypeDef IFR_config
 

Macro Definition Documentation

◆ BCD_TO_INT

#define BCD_TO_INT (   bcd)    ((bcd & 0xF) + ((bcd & 0xF0) >> 4)*10)

◆ BLE_UTIL_ACI_ERROR

#define BLE_UTIL_ACI_ERROR   3

◆ BLE_UTIL_CRC_ERROR

#define BLE_UTIL_CRC_ERROR   4

◆ BLE_UTIL_PARSE_ERROR

#define BLE_UTIL_PARSE_ERROR   5

◆ BLE_UTIL_SUCCESS

#define BLE_UTIL_SUCCESS   0

Return values

◆ BLE_UTIL_UNSUPPORTED_VERSION

#define BLE_UTIL_UNSUPPORTED_VERSION   1

◆ BLE_UTIL_WRONG_IMAGE_SIZE

#define BLE_UTIL_WRONG_IMAGE_SIZE   2

◆ BLE_UTIL_WRONG_VERIFY

#define BLE_UTIL_WRONG_VERIFY   6

◆ FROM_SYS_TIME_TO_US

#define FROM_SYS_TIME_TO_US (   sys)    ((uint16_t)(sys*2.4414))

◆ FROM_US_TO_SYS_TIME

#define FROM_US_TO_SYS_TIME (   us)    ((uint16_t)(us/2.4414)+1)

◆ INT_TO_BCD

#define INT_TO_BCD (   n)    ((((uint8_t)n/10)<<4) + (uint8_t)n%10)

Typedef Documentation

◆ IFR_config_TypeDef

typedef { ... } IFR_config_TypeDef

Structure inside IFR for configuration options.

Function Documentation

◆ change_IFR_data_config()

void change_IFR_data_config ( IFR_config2_TypeDef IFR_config,
uint8_t  data[64] 
)

Modify IFR data. (Last 64-bytes block).

Parameters
IFR_configStructure that contains the new parameters inside the IFR configuration data.
Note
It is highly recommended to parse the IFR configuration from a working IFR block (this should be done with parse_IFR_data_config()). Then it is possible to write the new parameters inside the IFR_config structure.
Parameters
dataPointer to the buffer that contains the original data. It will be modified according to the new data in the IFR_config structure. Then this data must be written in the last 64-byte block in the IFR. Its size must be 64 bytes.
Return values
None

◆ getBlueNRGUpdaterVersion()

uint8_t getBlueNRGUpdaterVersion ( uint8_t *  version)

Get BlueNRG updater version.

Parameters
versionThis parameter returns the updater version. If the updadter version is 0x03 the chip has the updater old, needs to update the bootloader.
Return values
Statusof the call

◆ getBlueNRGVersion()

uint8_t getBlueNRGVersion ( uint8_t *  hwVersion,
uint16_t *  fwVersion 
)

Get BlueNRG hardware and firmware version.

Parameters
hwVersionThis parameter returns the Hardware Version (i.e. CUT 3.0 = 0x30, CUT 3.1 = 0x31).
fwVersionThis parameter returns the Firmware Version in the format 0xJJMN where JJ = Major Version number, M = Minor Version number and N = Patch Version number.
Return values
Statusof the call

◆ IFR_validate()

int IFR_validate ( IFR_config2_TypeDef IFR_config)

Check for the correctness of parsed data.

Parameters
IFR_configData structure filled with parsed data.
Return values
intIt returns 0 if successful, or PARSE_ERROR in case data is not correct.

◆ isHWBootloader_Patched()

uint8_t isHWBootloader_Patched ( void  )

Verifies if the bootloader is patched or not. This function shall be used to fix a bug on the HW bootloader related to the 32 MHz external crystal oscillator.

Return values
TRUEif the HW bootloader is already patched, FALSE otherwise

◆ parse_IFR_data_config()

void parse_IFR_data_config ( const uint8_t  data[64],
IFR_config2_TypeDef IFR_config 
)

Parse IFR raw data.

Parameters
dataPointer to the raw data: last 64 bytes read from IFR sector.
IFR_configData structure that will be filled with parsed data.
Return values
None

◆ program_device()

int program_device ( const uint8_t *  fw_image,
uint32_t  fw_size 
)

Flash a new firmware using internal bootloader.

Parameters
fw_imagePointer to the firmware image (raw binary data, little-endian).
fw_sizeSize of the firmware image. The firmware image size shall be multiple of 4 bytes.
Return values
intIt returns 0 if successful, or a number not equal to 0 in case of error (ACI_ERROR, UNSUPPORTED_VERSION, WRONG_IMAGE_SIZE, CRC_ERROR)

◆ program_IFR()

int program_IFR ( const IFR_config_TypeDef ifr_image)

Program raw data to IFR (3 64-bytes blocks).

Parameters
ifr_imagePointer to the buffer that will contain the data to program. Its size must be 192 bytes.
Return values
intIt returns 0 if successful

◆ read_IFR()

int read_IFR ( uint8_t  data[192])

Read raw data from IFR (3 64-bytes blocks).

Parameters
dataPointer to the buffer that will contain the read data. Its size must be 192 bytes. This data can be parsed by parse_IFR_data_config().
Return values
intIt returns 0 if successful, or a number not equal to 0 in case of error (ACI_ERROR, UNSUPPORTED_VERSION)

◆ verify_IFR()

uint8_t verify_IFR ( const IFR_config_TypeDef ifr_data)

Verify raw data from IFR (3 64-bytes blocks).

Parameters
ifr_dataPointer to the buffer that will contain the data to verify. Its size must be 192 bytes.
Return values
intIt returns 0 if successful, or a number not equal to 0 in case of error (ACI_ERROR, BLE_UTIL_WRONG_VERIFY)

Variable Documentation

◆ cold_ana_act_config_table

uint8_t cold_ana_act_config_table[64]

◆ day

uint8_t day

◆ gpio_config

uint8_t gpio_config

◆ hot_ana_config_table

uint8_t hot_ana_config_table[64]

◆ hs_startup_time

uint16_t hs_startup_time

◆ IFR_config

const IFR_config_TypeDef IFR_config

◆ ls_crystal_freq

uint32_t ls_crystal_freq

◆ ls_crystal_period

uint32_t ls_crystal_period

◆ master_sca

uint8_t master_sca

◆ max_conn_event_time

uint32_t max_conn_event_time

◆ month

uint8_t month

◆ rsrvd1

uint8_t rsrvd1[2]

◆ rsrvd2

uint32_t rsrvd2[3]

◆ rsrvd3

uint8_t rsrvd3

◆ rsrvd4

uint8_t rsrvd4[2]

◆ rsrvd5

uint8_t rsrvd5

◆ slave_sca_ppm

uint16_t slave_sca_ppm

◆ stack_mode

uint8_t stack_mode

◆ uid

uint32_t uid

◆ unused

uint32_t unused[5]

◆ year

uint8_t year
Generated on Mon Apr 15 2019 18:10:39 for BlueNRG-MS pack for STM32CubeMX by   doxygen 1.8.13