Microchip® Advanced Software Framework

bm_program_mode.c File Reference

BM program mode definitions.

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

#include "platform_files.h"
#include "bm_program_mode.h"
#include "event_mem.h"

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 ()
 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...
 

Variables

event_t appEvent
 
static BM_PROGRAM_CMDPKT pgmCmdPkt
 
static BM_PROGRAM_CMD_STATE pgmCmdState = BM_PGM_HCI_EVENT
 
static uint8_t pgmDataCmdPkt [BM_PGM_PKT_LEN_MAX]
 
static uint16_t pgmDataIndex = 0
 
static uint8_t pgmRspData [BM_PGM_PKT_LEN_MAX]
 

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().

event_t appEvent

Referenced by get_received_cmd_frame().

BM_PROGRAM_CMDPKT pgmCmdPkt
static

Referenced by BM_PROGRAM_Init().

uint8_t pgmDataCmdPkt[BM_PGM_PKT_LEN_MAX]
static

Referenced by BM_PROGRAM_Init().

uint16_t pgmDataIndex = 0
static
uint8_t pgmRspData[BM_PGM_PKT_LEN_MAX]
static