Board Layer

Last Updated on : 2022-11-24 09:20:05download

The board layer contains the Bluetooth abstraction layer and the hardware abstraction layer, namely the SDK from the chip manufacturer as well as the adaptation files for integrating with the Tuya IoT Development Platform.

Bluetooth abstraction layer

This layer includes the bal_beacon_txrx(u32 tx_cnt, u32 rx_cnt) that is used to receive and transmit the Beacon data.

bal_beacon_txrx

Function bal_beacon_txrx
Feature description Used to receive and transmit the Beacon data.
Parameter tx_cnt: the total number of times that the channels 37, 38, and 39 transmit the Beacon data in turn. The value must be multiples of 3.
rx_cnt: the total number of times that the channels 37, 38, and 39 receive the Beacon data in turn. The value must be multiples of 3.
Return value None
Note The Beacon data to be transmitted and received is stored on tx_buf[31] and rx_buf[39] respectively. Make sure to directly use the sample code without any modifications.
  • If your system cannot process receiving and transmission in parallel, make sure transmission is followed by receiving.
  • If possible, you can leave the receive function always on and call it in the receive callback.
  • If possible, set the transmission interval to the minimum.

Hardware abstraction layer

To store anti-replay sequence numbers and encryption keys and provide the timer function, you need to implement a 256-byte nonvolatile random-access memory (NVRAM) driver and a microseconds system tick driver.

hal_storage_256_init

Function hal_storage_256_init
Feature description Used to initialize a 256-byte NVRAM driver.
Parameter None
Return value 0
Note Implement this function as required.

hal_storage_256_read_bytes

Function hal_storage_256_read_bytes
Feature description Used to read data in specified length from an address space.
Parameter u16 offset: the address offset.
u8* pdata: the data to be read.
u8 len: the length of the data to be read.
Return value 0
Note Implement this function as required. A dual backup is recommended.

hal_storage_256_write_bytes

Function hal_storage_256_write_bytes
Feature description Used to write data in specified length to an address space.
Parameter u16 offset: the address offset.
u8* pdata: the data to be written.
u8 len: the length of the data to be written.
Return value 0
Note Implement this function as required. A dual backup is recommended.

hal_clock_get_system_tick

Function hal_clock_get_system_tick
Feature description Used to get the current tick value.
Parameter None
Return value The tick value.
Note Implement this function as required.

hal_clock_time_exceed

Function hal_clock_time_exceed
Feature description Used to determine whether the result of the current tick minus the old_tick exceeds the specified span_us. If it does, true is returned.
Parameter u32 ref: old_tick: the tick value when a timer starts.
u32 span_us: the specified timer span.
Return value true: 1
false: 0
Note Implement this function as required.