BMLite_Nordic/BMLite_example/inc/bmlite_hal.h
Andrey Perminov 22f24e6a82 Code refactoring
Moved all HW-dependent function definitions to bmlite_hal.h
Moved all HW-dependent function implementations to hal_*.c

Change-Id: I5f592fcffab1ef4bb815f90b968be638d33d0a5d
2020-04-22 15:28:34 -07:00

90 lines
1.7 KiB
C
Executable File

/**
* @file bmlite.h
* @brief BM-Lite HAL functions.
*
* All functions must be implemented in order to support BM-Lite on a Board
*/
#ifndef BMLITE_H
#define BMLITE_H
#include "fpc_bep_types.h"
#include "platform.h"
/*
* @brief Board initialization
* @param[in] SPI CLK speed
*/
void hal_board_init(uint32_t speed_hz);
/*
* @brief Control BM-Lite Reset pin
* @param[in] True - Activate RESET
* False - Deactivate RESET
*/
void hal_bmlite_reset(bool state);
/*
* @brief Init SPI interface
* @param[in] SPI CLK speed
*/
void hal_bmlite_spi_init(uint32_t speed_hz);
/*
* @brief SPI write-read
* @param[in] Write buffer
* @param[in] Read buffer
* @param[in] Size
* @param[in] Leave CS asserted
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t hal_bmlite_spi_write_read(uint8_t *write, uint8_t *read, size_t size,
bool leave_cs_asserted);
/*
* @brief Check if BM-Lite IRQ pin is set
* @return ::bool
*/
bool hal_bmlite_get_status(void);
/**
* @brief Initializes timebase. Starts system tick counter.
*/
void hal_timebase_init(void);
/**
* @brief Reads the system tick counter.
*
* @return Tick count since hal_timebase_init() call. [ms]
*/
uint32_t hal_timebase_get_tick(void);
/**
* @brief Busy wait.
*
* @param[in] ms Time to wait [ms].
* 0 => return immediately
* 1 => wait at least 1ms etc.
*/
void hal_timebase_busy_wait(uint32_t ms);
/*
* Optional functions for Buttons & Leds control
*/
/*
* @brief Get button press time (msec)
* @return ::uint32_t
*/
uint32_t hal_get_button_press_time();
/*
* @brief Set LED(s) status
* @param[in] Status
*/
void hal_set_leds(uint8_t status);
#endif /* BMLITE_H */