Functions

static hal_i2c_handlehal_i2c_get_handle (KI2CNum num)
 Fetches i2c bus data structure. More...
 
static hal_i2c_handlehal_i2c_device_init (KI2C *i2c)
 Initializes i2c bus structure with data needed to setup hardware. More...
 
static KI2CStatus hal_i2c_hw_init (hal_i2c_handle *handle)
 Initializes the I2C according to the specified parameters in the I2C_InitTypeDef and create the associated handle. More...
 
static void hal_i2c_msp_init (hal_i2c_handle *handle)
 Low level I2C hardware setup. More...
 
static void hal_i2c_terminate (hal_i2c_handle *handle)
 I2C hardware cleanup and disabling. More...
 
static KI2CStatus hal_i2c_check_addr_timeout (I2C_HandleTypeDef *handle, uint32_t flag)
 Checks for the addr flag to be set, with builtin timeout. More...
 
static KI2CStatus hal_i2c_check_flag_special (I2C_HandleTypeDef *handle, uint32_t flag)
 Checks for special conditions based on the flag. More...
 
static KI2CStatus hal_i2c_check_flag_timeout (I2C_HandleTypeDef *handle, uint32_t flag, uint16_t status)
 Checks specified flag for desired state, with builtin timeout. More...
 
static KI2CStatus hal_i2c_check_btf_timeout (I2C_HandleTypeDef *handle)
 Checks for btf flag to reset, with builtin timeout. More...
 
static KI2CStatus hal_i2c_check_txe_timeout (I2C_HandleTypeDef *handle)
 Checks for txe flag to reset, with builtin timeout. More...
 
static KI2CStatus hal_i2c_master_request_read (I2C_HandleTypeDef *hal_handle, uint16_t addr)
 Master sends slave address for read request. More...
 
static KI2CStatus hal_i2c_master_setup_read (I2C_HandleTypeDef *hal_handle, uint16_t addr, int len)
 Sends initial receive sequence based on length of data expected. More...
 
static KI2CStatus hal_i2c_master_request_write (I2C_HandleTypeDef *hal_handle, uint16_t addr)
 Master sends slave address for write request. More...
 
static KI2CStatus hal_i2c_master_setup_write (I2C_HandleTypeDef *hal_handle, uint16_t addr)
 Sends initial transmit sequence. More...
 
KI2CStatus kprv_i2c_dev_init (KI2CNum i2c_num)
 Setup and enable i2c bus. More...
 
KI2CStatus kprv_i2c_dev_terminate (KI2CNum i2c)
 i2c hardware cleanup and disabling More...
 
KI2CStatus kprv_i2c_master_write (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len)
 Write data over i2c bus as master. More...
 
KI2CStatus kprv_i2c_master_read (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len)
 Read data over i2c bus as master. More...
 

Variables

static hal_i2c_handle hal_i2c_bus [K_NUM_I2CS]
 Static array of i2c bus handles. More...
 

Function Documentation

static KI2CStatus hal_i2c_check_addr_timeout ( I2C_HandleTypeDef *  handle,
uint32_t  flag 
)
static

Checks for the addr flag to be set, with builtin timeout.

Note
Derived from STM32CubeF4's I2C_WaitOnMasterAddressFlagUntilTimeout
Parameters
handlePointer to STM32CubeF4 HAL defined structure for I2C data
flagI2C flag to check
Returns
KI2CStatus I2C_OK if success, otherwise a specific error flag
static KI2CStatus hal_i2c_check_btf_timeout ( I2C_HandleTypeDef *  handle)
static

Checks for btf flag to reset, with builtin timeout.

Note
Derived from STM32CubeF4's I2C_WaitOnBTFFlagUntilTimeout
Parameters
handlePointer to STM32CubeF4 HAL defined structure for I2C data
Returns
KI2CStatus I2C_OK if btf is reset within timeout, otherwise specific error
static KI2CStatus hal_i2c_check_flag_special ( I2C_HandleTypeDef *  handle,
uint32_t  flag 
)
static

Checks for special conditions based on the flag.

Parameters
handlePointer to STM32CubeF4 HAL defined structure for I2C data
flagI2C Flag that should be checked
Returns
KI2CStatus I2C_OK if no special conditions found, specific error otherwise
static KI2CStatus hal_i2c_check_flag_timeout ( I2C_HandleTypeDef *  handle,
uint32_t  flag,
uint16_t  status 
)
static

Checks specified flag for desired state, with builtin timeout.

Note
Derived from STM32CubeF4's I2C_WaitOnFlagUntilTimeout
Parameters
handlePointer to STM32CubeF4 HAL defined structure for I2C data
flagI2C Flag that should be checked
statusIndicates whether to check for flag state of SET or RESET
Returns
KI2CStatus I2C_OK if flag is set to desired value within timout, otherwise I2C_TIMEOUT
static KI2CStatus hal_i2c_check_txe_timeout ( I2C_HandleTypeDef *  handle)
static

Checks for txe flag to reset, with builtin timeout.

Note
Derived from STM32CubeF4's I2C_WaitOnBTFFlagUntilTimeout
Parameters
handlePointer to STM32CubeF4 HAL defined structure for I2C data
Returns
KI2CStatus I2C_OK if txe is reset within timeout, otherwise specific error
static hal_i2c_handle * hal_i2c_device_init ( KI2C *  i2c)
static

Initializes i2c bus structure with data needed to setup hardware.

Parameters
i2chigher level hal i2c data
Returns
hal_i2c_handle* NULL if bad bus num, otherwise data ready for dev setup
static hal_i2c_handle * hal_i2c_get_handle ( KI2CNum  num)
static

Fetches i2c bus data structure.

Parameters
numi2c bus num to fetch
Returns
hal_i2c_handle* pointer to data structure
static KI2CStatus hal_i2c_hw_init ( hal_i2c_handle handle)
static

Initializes the I2C according to the specified parameters in the I2C_InitTypeDef and create the associated handle.

Note
Derived from STM32CubeF4's HAL_I2C_INIT
Parameters
handlepointer to hal_i2c_handle containing config information
Returns
KI2CStatus I2C_OK if success, otherwise a specific error flag
static KI2CStatus hal_i2c_master_request_read ( I2C_HandleTypeDef *  hal_handle,
uint16_t  addr 
)
static

Master sends slave address for read request.

Note
Derived from STM32CubeF4's I2C_MasterRequestRead
Parameters
handlePointer to STM32CubeF4 HAL defined structure for I2C data
addrtarget slave address
Returns
KI2CStatus I2C_OK if success, otherwise specific error
static KI2CStatus hal_i2c_master_request_write ( I2C_HandleTypeDef *  hal_handle,
uint16_t  addr 
)
static

Master sends slave address for write request.

Note
Derived from STM32CubeF4's I2C_MasterRequestWrite
Parameters
handlePointer to STM32CubeF4 HAL defined structure for I2C data
addrtarget slave address
Returns
KI2CStatus I2C_OK if success, otherwise specific error
static KI2CStatus hal_i2c_master_setup_read ( I2C_HandleTypeDef *  hal_handle,
uint16_t  addr,
int  len 
)
static

Sends initial receive sequence based on length of data expected.

Note
Partly derived from STM32CubeF4's HAL_I2C_Master_Receive
Parameters
handlePointer to STM32CubeF4 HAL defined structure for I2C data
addrtarget slave address
lenlength of data expected to be received
Returns
KI2CStatus I2C_OK if success, otherwise specific error
static KI2CStatus hal_i2c_master_setup_write ( I2C_HandleTypeDef *  hal_handle,
uint16_t  addr 
)
static

Sends initial transmit sequence.

Note
Derived from STM32CubeF4's HAL_I2C_Master_Transmit
Parameters
handlePointer to STM32CubeF4 HAL defined structure for I2C data
addrtarget slave address
Returns
KI2CStatus I2C_OK if success, otherwise specific error
static void hal_i2c_msp_init ( hal_i2c_handle handle)
static

Low level I2C hardware setup.

Note
Derived from STM32CubeF4's HAL_I2C_MspInit
Parameters
handlepointer to hal_i2c_handle containing config information
static void hal_i2c_terminate ( hal_i2c_handle handle)
static

I2C hardware cleanup and disabling.

Parameters
handlepointer to hal_i2c_handle containing config information
KI2CStatus kprv_i2c_dev_init ( KI2CNum  i2c_num)

Setup and enable i2c bus.

Parameters
i2ci2c bus to initialize
Returns
KI2CStatus I2C_OK if success, otherwise a specific error flag
KI2CStatus kprv_i2c_dev_terminate ( KI2CNum  i2c)

i2c hardware cleanup and disabling

Parameters
i2cbus num to terminate
Returns
KI2CStatus I2C_OK if success, otherwise a specific error flag
KI2CStatus kprv_i2c_master_read ( KI2CNum  i2c,
uint16_t  addr,
uint8_t *  ptr,
int  len 
)

Read data over i2c bus as master.

Parameters
i2ci2c bus to read from
addri2c address to write to
ptrpointer to data buffer
lenlength of data to read
Returns
KI2CStatus I2C_OK on success, otherwise failure
KI2CStatus kprv_i2c_master_write ( KI2CNum  i2c,
uint16_t  addr,
uint8_t *  ptr,
int  len 
)

Write data over i2c bus as master.

Parameters
i2ci2c bus to write to
addri2c address to write to
ptrpointer to data buffer
lenlength of data to write
Returns
KI2CStatus I2C_OK on success, otherwise failure

Variable Documentation

hal_i2c_handle hal_i2c_bus[K_NUM_I2CS]
static

Static array of i2c bus handles.