Microchip® Advanced Software Framework

bm_program_mode.h File Reference

BM program mode declarations.

Copyright (c) 2018 Microchip Technology Inc. and its subsidiaries.

#include "stdint.h"
#include "stdbool.h"
#include "stdlib.h"
#include "string.h"

Data Structures

struct  _bm_program_cmd
 
struct  _bm_program_cmdpkt
 
struct  _bm_program_event
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 
struct  PACKED
 Blue-tooth Low Energy address Type. More...
 

Macros

#define BM_PGM_HCI_ACL_VAL   0x02
 
#define BM_PGM_HCI_EVENT_VAL   0x04
 
#define BM_PGM_PKT_LEN_MAX   320
 

Typedefs

typedef enum _bm_pgm_hci_acl_index BM_PGM_HCI_ACL_INDEX
 
typedef enum _bm_pgm_hci_index BM_PGM_HCI_INDEX
 
typedef struct _bm_program_cmd BM_PROGRAM_CMD
 
typedef enum _bm_program_cmd_state BM_PROGRAM_CMD_STATE
 
typedef struct _bm_program_cmdpkt BM_PROGRAM_CMDPKT
 
typedef struct PACKED BM_PROGRAM_CONNECT_PKT
 
typedef struct PACKED BM_PROGRAM_CRC_PKT
 
typedef struct PACKED BM_PROGRAM_DATA_ALT_PKT
 
typedef struct PACKED BM_PROGRAM_DATA_PKT
 
typedef struct PACKED BM_PROGRAM_DISCONNECT_PKT
 
typedef struct _bm_program_event BM_PROGRAM_EVENT
 
typedef struct PACKED BM_PROGRAM_EVENT_COMPLETE_PKT
 
typedef struct PACKED BM_PROGRAM_EVENT_CONN_PKT
 
typedef struct PACKED BM_PROGRAM_EVENT_DATA_PKT
 
typedef struct PACKED BM_PROGRAM_EVENT_DISCONN_PKT
 
typedef struct PACKED BM_PROGRAM_EVENT_NOCP_PKT
 
typedef struct PACKED BM_PROGRAM_EVENT_STATUS_PKT
 
typedef enum
_bm_program_hci_event_id 
BM_PROGRAM_HCI_EVENT_ID
 
typedef enum
_bm_program_hci_event_status 
BM_PROGRAM_HCI_EVENT_STATUS
 
typedef struct PACKED HCI_COMMAND_PKT
 
typedef struct PACKED HCI_DATA_PKT
 
typedef struct PACKED HCI_EVENT_PKT
 

Enumerations

enum  _bm_pgm_hci_acl_index {
  BM_PGM_HCI_ACL_HANDLEL_INDEX = 0x01,
  BM_PGM_HCI_ACL_HANDLEH_INDEX,
  BM_PGM_HCI_ACL_LENL_INDEX,
  BM_PGM_HCI_ACL_LENH_INDEX,
  BM_PGM_HCI_ACL_DATA_INDEX
}
 
enum  _bm_pgm_hci_index {
  BM_PGM_HCI_EVENT_INDEX = 0x00,
  BM_PGM_HCI_EVENT_TYPE_INDEX,
  BM_PGM_HCI_EVENT_LEN_INDEX,
  BM_PGM_HCI_EVENT_DATA_INDEX
}
 
enum  _bm_program_cmd_state {
  BM_PGM_HCI_EVENT = 0x00,
  BM_PGM_HCI_EVENT_TYPE,
  BM_PGM_HCI_EVENT_LEN,
  BM_PGM_HCI_EVENT_DATA,
  BM_PGM_HCI_ACL_HANDLEH,
  BM_PGM_HCI_ACL_HANDLEL,
  BM_PGM_HCI_ACL_LENH,
  BM_PGM_HCI_ACL_LENL,
  BM_PGM_HCI_ACL_DATA
}
 
enum  _bm_program_hci_event_id {
  BM_PROGRAM_HCI_CONN = 0x03,
  BM_PROGRAM_HCI_DISCONN = 0x05,
  BM_PROGRAM_HCI_COMPLETE = 0x0E,
  BM_PROGRAM_HCI_STATUS = 0x0F,
  BM_PROGRAM_HCI_NOCP = 0x13,
  BM_PROGRAM_HCI_ERROR = 0xFF
}
 
enum  _bm_program_hci_event_status {
  BM_PROGRAM_HCI_SUCCESS = 0x00,
  BM_PROGRAM_HCI_HANDLE = 0x01,
  BM_PROGRAM_HCI_FAIL
}
 
enum  HCI_PKT_TYPE {
  COMMAND_PKT_TYPE = 0x01,
  DATA_ACL_PKT_TYPE = 0x02,
  EVENT_PKT_TYPE = 0x04
}
 

Functions

void BM_PROGRAM_Connect (BM_PROGRAM_CMDPKT *programCmdPkt)
 Connect command to connect to BM70 in PROGRAM mode. More...
 
void BM_PROGRAM_CRC_Get (BM_PROGRAM_CMDPKT *programCmdPkt, BM_PROGRAM_CMD *pgm_cmd)
 Builds a program mode command packet to get CRC of the program memory. More...
 
void BM_PROGRAM_DeInit (BM_PROGRAM_CMDPKT *programCmdPkt)
 De-initializes PROGRAM mode configuration library. More...
 
void BM_PROGRAM_Disconnect (BM_PROGRAM_CMDPKT *programCmdPkt)
 Disconnect command to disconnect from BM70 in PROGRAM mode. More...
 
void BM_PROGRAM_Erase (BM_PROGRAM_CMDPKT *programCmdPkt, BM_PROGRAM_CMD *pgm_cmd)
 Builds a program mode command packet to erase the program memory. More...
 
BM_PROGRAM_CMDPKTBM_PROGRAM_Init (void)
 Initializes program mode. More...
 
void BM_PROGRAM_Read (BM_PROGRAM_CMDPKT *programCmdPkt, BM_PROGRAM_CMD *pgm_cmd)
 Builds a program mode command packet to read the program memory. More...
 
bool BM_PROGRAM_ResponseCheck (uint8_t *data, uint8_t len)
 Parses the event packet and provides the handle to the event. More...
 
void BM_PROGRAM_Write (BM_PROGRAM_CMDPKT *programCmdPkt, BM_PROGRAM_CMD *pgm_cmd)
 Builds a program mode command packet to write the program memory. More...
 
void BM_PROGRAM_Write_Continue (BM_PROGRAM_CMDPKT *programCmdPkt, BM_PROGRAM_CMD *pgm_cmd)
 Builds a program mode command packet to continue writing the program memory. More...
 

#define BM_PGM_HCI_ACL_VAL   0x02
#define BM_PGM_HCI_EVENT_VAL   0x04
#define BM_PGM_PKT_LEN_MAX   320

typedef struct PACKED BM_PROGRAM_CRC_PKT
typedef struct PACKED BM_PROGRAM_DATA_PKT
typedef struct PACKED HCI_COMMAND_PKT
typedef struct PACKED HCI_DATA_PKT
typedef struct PACKED HCI_EVENT_PKT

Enumerator
BM_PGM_HCI_ACL_HANDLEL_INDEX 
BM_PGM_HCI_ACL_HANDLEH_INDEX 
BM_PGM_HCI_ACL_LENL_INDEX 
BM_PGM_HCI_ACL_LENH_INDEX 
BM_PGM_HCI_ACL_DATA_INDEX 
Enumerator
BM_PGM_HCI_EVENT_INDEX 
BM_PGM_HCI_EVENT_TYPE_INDEX 
BM_PGM_HCI_EVENT_LEN_INDEX 
BM_PGM_HCI_EVENT_DATA_INDEX 
Enumerator
BM_PGM_HCI_EVENT 
BM_PGM_HCI_EVENT_TYPE 
BM_PGM_HCI_EVENT_LEN 
BM_PGM_HCI_EVENT_DATA 
BM_PGM_HCI_ACL_HANDLEH 
BM_PGM_HCI_ACL_HANDLEL 
BM_PGM_HCI_ACL_LENH 
BM_PGM_HCI_ACL_LENL 
BM_PGM_HCI_ACL_DATA 
Enumerator
BM_PROGRAM_HCI_CONN 
BM_PROGRAM_HCI_DISCONN 
BM_PROGRAM_HCI_COMPLETE 
BM_PROGRAM_HCI_STATUS 
BM_PROGRAM_HCI_NOCP 
BM_PROGRAM_HCI_ERROR 
Enumerator
BM_PROGRAM_HCI_SUCCESS 
BM_PROGRAM_HCI_HANDLE 
BM_PROGRAM_HCI_FAIL 
Enumerator
COMMAND_PKT_TYPE 
DATA_ACL_PKT_TYPE 
EVENT_PKT_TYPE 

void BM_PROGRAM_Connect ( BM_PROGRAM_CMDPKT programCmdPkt)

Connect command to connect to BM70 in PROGRAM mode.

Builds a program mode command packet t0 connect to program memory to start the program mode.

Parameters
programCmdPktHandle to the PROGRAM mode command packet created by connect function.
Precondition
PROGRAM configuration library initialization function must be used to initialize the programCmdPkt.
Returns
None.
Parameters
programCmdPktHandle to the program mode command packet.
Precondition
Program mode initialization function mut be called to initialize the programCmdPkt.
Returns
None.

References PACKED::addr, COMMAND_PKT_TYPE, PACKED::hci_command_pkt, PACKED::length, PACKED::mode, PACKED::offset, PACKED::opcode, PACKED::role, and PACKED::type.

Referenced by dfu_init().

void BM_PROGRAM_CRC_Get ( BM_PROGRAM_CMDPKT programCmdPkt,
BM_PROGRAM_CMD pgm_cmd 
)

Builds a program mode command packet to get CRC of the program memory.

Parameters
programCmdPktHandle to the program mode command packet.
pgm_cmdHandle to the program mode data packet.
Precondition
Program mode connect function mut be called.
Returns
None.

References PACKED::acl_data_pkt, PACKED::address, PACKED::conn_handle, PACKED::crc_algo, DATA_ACL_PKT_TYPE, PACKED::length, PACKED::pgm_cmd_id, PACKED::pgm_data_len, PACKED::pgm_mem_subtype, PACKED::pgm_mem_type, PACKED::size, and PACKED::type.

void BM_PROGRAM_DeInit ( BM_PROGRAM_CMDPKT programCmdPkt)

De-initializes PROGRAM mode configuration library.

De-initializes program mode.

Parameters
programCmdPktHandle to the PROGRAM mode command packet created by init function.
Precondition
PROGRAM configuration library initialization function must be used to initialize the programCmdPkt.
Returns
None.
Parameters
programCmdPktHandle to the program mode command packet.
Precondition
None.
Returns
None.
void BM_PROGRAM_Disconnect ( BM_PROGRAM_CMDPKT programCmdPkt)

Disconnect command to disconnect from BM70 in PROGRAM mode.

Builds a program mode command packet to disconnect from program memory to stop the program mode.

Parameters
programCmdPktHandle to the PROGRAM mode command packet created by connect function.
Precondition
PROGRAM configuration library initialization function must be used to initialize the programCmdPkt. The PROGRAM configuration library de-initialization function must be called after calling disconnect function.
Returns
None.
Parameters
programCmdPktHandle to the program mode command packet.
Precondition
Program mode connect function mut be called.
Returns
None.

References COMMAND_PKT_TYPE, PACKED::conn_handle, PACKED::hci_command_pkt, PACKED::length, PACKED::opcode, PACKED::reason, and PACKED::type.

Referenced by dfu_deinit().

void BM_PROGRAM_Erase ( BM_PROGRAM_CMDPKT programCmdPkt,
BM_PROGRAM_CMD pgm_cmd 
)

Builds a program mode command packet to erase the program memory.

Parameters
programCmdPktHandle to the program mode command packet.
pgm_cmdHandle to the program mode data packet.
Precondition
Program mode connect function mut be called.
Returns
None.

References PACKED::acl_data_pkt, PACKED::address, PACKED::conn_handle, DATA_ACL_PKT_TYPE, PACKED::length, PACKED::pgm_cmd_id, PACKED::pgm_data_len, PACKED::pgm_mem_subtype, PACKED::pgm_mem_type, PACKED::size, and PACKED::type.

Referenced by dfu_program_memory_erase().

BM_PROGRAM_CMDPKT * BM_PROGRAM_Init ( void  )

Initializes program mode.

Parameters
None.
Precondition
None.
Returns
Handle to the program mode command packet.

References BM_PROGRAM_HCI_ERROR, event_msg_t::data, event_msg_t::data_len, event_t::event_id, event_t::event_msg, NULL, pgmCmdPkt, and pgmDataCmdPkt.

Referenced by dfu_init().

void BM_PROGRAM_Read ( BM_PROGRAM_CMDPKT programCmdPkt,
BM_PROGRAM_CMD pgm_cmd 
)

Builds a program mode command packet to read the program memory.

Parameters
programCmdPktHandle to the program mode command packet.
pgm_cmdHandle to the program mode data packet.
Precondition
Program mode connect function mut be called.
Returns
None.

References PACKED::acl_data_pkt, PACKED::address, PACKED::conn_handle, DATA_ACL_PKT_TYPE, PACKED::length, PACKED::pgm_cmd_id, PACKED::pgm_data_len, PACKED::pgm_mem_subtype, PACKED::pgm_mem_type, PACKED::size, and PACKED::type.

Referenced by dfu_program_memory_read().

bool BM_PROGRAM_ResponseCheck ( uint8_t *  data,
uint8_t  len 
)
void BM_PROGRAM_Write ( BM_PROGRAM_CMDPKT programCmdPkt,
BM_PROGRAM_CMD pgm_cmd 
)

Builds a program mode command packet to write the program memory.

Parameters
programCmdPktHandle to the program mode command packet.
pgm_cmdHandle to the program mode data packet.
Precondition
Program mode connect function mut be called.
Returns
None.

References PACKED::acl_data_pkt, PACKED::address, PACKED::conn_handle, DATA_ACL_PKT_TYPE, PACKED::length, PACKED::pgm_cmd_id, PACKED::pgm_data_len, PACKED::pgm_mem_subtype, PACKED::pgm_mem_type, PACKED::size, and PACKED::type.

Referenced by dfu_program_memory_write(), and dfu_program_memory_write_continue().

void BM_PROGRAM_Write_Continue ( BM_PROGRAM_CMDPKT programCmdPkt,
BM_PROGRAM_CMD pgm_cmd 
)

Builds a program mode command packet to continue writing the program memory.

Parameters
programCmdPktHandle to the program mode command packet.
pgm_cmdHandle to the program mode data packet.
Precondition
Program mode connect function mut be called.
Returns
None.

References PACKED::acl_data_pkt, PACKED::conn_handle, DATA_ACL_PKT_TYPE, PACKED::length, PACKED::pgm_cmd_id, PACKED::pgm_data_len, and PACKED::type.

Referenced by dfu_program_memory_write_continue().