nrf5/hal: Updating TWI with frequency enums.

This commit is contained in:
Glenn Ruben Bakke 2017-01-28 22:54:44 +01:00
parent 726fe1aa27
commit 1c778f020f
3 changed files with 35 additions and 10 deletions

View File

@ -29,6 +29,12 @@
#ifdef HAL_TWI_MODULE_ENABLED
static const uint32_t hal_twi_frequency_lookup[] = {
TWI_FREQUENCY_FREQUENCY_K100, // 100 kbps
TWI_FREQUENCY_FREQUENCY_K250, // 250 kbps
TWI_FREQUENCY_FREQUENCY_K400, // 400 kbps
};
void hal_twi_init(NRF_TWI_Type * p_instance, hal_twi_init_t const * p_twi_init) {
}

View File

@ -60,25 +60,38 @@ typedef struct {
#endif
/**
* @brief TWI Configuration Structure definition
* @brief TWI clock frequency type definition
*/
typedef struct {
} hal_twi_init_t;
typedef enum {
HAL_TWI_FREQ_100_Kbps = 0,
HAL_TWI_FREQ_250_Kbps,
HAL_TWI_FREQ_400_Kbps
} hal_twi_clk_freq_t;
/**
* @brief TWI role type definition
*/
typedef enum {
HAL_TWI_MASTER,
HAL_TWI_SLAVE
} hal_twi_mode_t;
} hal_twi_role_t;
/**
* @brief TWI Configuration Structure definition
*/
typedef struct {
uint8_t id; /* TWI instance id */
hal_twi_role_t role; /* TWI master/slave */
hal_twi_clk_freq_t freq; /* TWI frequency */
} hal_twi_init_t;
/**
* @brief TWI handle Structure definition
*/
typedef struct __TWI_HandleTypeDef
{
NRF_TWI_Type *instance; /* TWI register base address */
hal_twi_init_t init; /* TWI initialization parameters */
uint8_t id; /* TWI instance id */
hal_twi_mode_t mode; /* TWI master/slave */
NRF_TWI_Type *instance; /* TWI register base address */
hal_twi_init_t init; /* TWI initialization parameters */
} TWI_HandleTypeDef;
void hal_twi_init(NRF_TWI_Type * p_instance, hal_twi_init_t const * p_twi_init);

View File

@ -27,14 +27,20 @@
#include "mphalport.h"
#include "hal_twi.h"
#ifdef HAL_TWIM_MODULE_ENABLED
#ifdef HAL_TWIE_MODULE_ENABLED
// EasyDMA variants
#define TWI_MASTER_BASE(x) ((NRF_TWIM_Type *)TWI_BASE_POINTERS[x])
#define TWI_SLAVE_BASE(x) ((NRF_TWIS_Type *)TWI_BASE_POINTERS[x])
static const uint32_t hal_twi_frequency_lookup[] = {
TWIM_FREQUENCY_FREQUENCY_K100, // 100 kbps
TWIM_FREQUENCY_FREQUENCY_K250, // 250 kbps
TWIM_FREQUENCY_FREQUENCY_K400, // 400 kbps
};
void hal_twi_init(NRF_TWI_Type * p_instance, hal_twi_init_t const * p_twi_init) {
}
#endif // HAL_TWIM_MODULE_ENABLED
#endif // HAL_TWIE_MODULE_ENABLED