LCM — CH32V003 Light Control Module
Light Control Module, I2C slave
Loading...
Searching...
No Matches
lcm_i2c.c File Reference
#include "lcm_i2c.h"
#include "lcm_module.h"
#include "lcm_led.h"
#include "event_log.h"
#include "ch32v00x_conf.h"

Go to the source code of this file.

Enumerations

enum  LCM_I2C_RxState { LCM_I2C_WAIT_CMD = 0 , LCM_I2C_WAIT_PARAM , LCM_I2C_ARMED_READ }
 

Functions

static uint8_t LCM_IsTwoByteCmd (uint8_t cmd)
 
static uint8_t LCM_IsReadCmd (uint8_t cmd)
 
static void LCM_I2C_ResetRx (void)
 
static void LCM_I2C_OnRxData (uint8_t byte)
 
void LCM_I2C_ArmRead (uint8_t byte)
 
void LCM_I2C_Init (uint8_t addr)
 
void I2C1_EV_IRQHandler (void)
 
void I2C1_ER_IRQHandler (void)
 

Variables

static volatile LCM_I2C_RxState s_i2c_rx_state = LCM_I2C_WAIT_CMD
 
static volatile uint8_t s_i2c_cmd
 
static volatile uint8_t s_i2c_tx_byte
 
static volatile uint8_t s_i2c_tx_pending
 

Enumeration Type Documentation

◆ LCM_I2C_RxState

Enumerator
LCM_I2C_WAIT_CMD 
LCM_I2C_WAIT_PARAM 
LCM_I2C_ARMED_READ 

Definition at line 29 of file lcm_i2c.c.

Function Documentation

◆ I2C1_ER_IRQHandler()

void I2C1_ER_IRQHandler ( void )

Definition at line 271 of file lcm_i2c.c.

◆ I2C1_EV_IRQHandler()

void I2C1_EV_IRQHandler ( void )

Definition at line 215 of file lcm_i2c.c.

◆ LCM_I2C_ArmRead()

void LCM_I2C_ArmRead ( uint8_t byte)

◆ LCM_I2C_Init()

void LCM_I2C_Init ( uint8_t addr)

Definition at line 136 of file lcm_i2c.c.

References LCM_I2C_ResetRx(), and LCM_I2C_SPEED_HZ.

Referenced by LCM_Module_Init().

◆ LCM_I2C_OnRxData()

◆ LCM_I2C_ResetRx()

static void LCM_I2C_ResetRx ( void )
static

Definition at line 83 of file lcm_i2c.c.

References LCM_I2C_WAIT_CMD, s_i2c_cmd, s_i2c_rx_state, and s_i2c_tx_pending.

Referenced by LCM_I2C_Init().

◆ LCM_IsReadCmd()

static uint8_t LCM_IsReadCmd ( uint8_t cmd)
static

Definition at line 69 of file lcm_i2c.c.

References LCM_GET_ERROR, and LCM_GET_ID.

Referenced by LCM_I2C_OnRxData().

◆ LCM_IsTwoByteCmd()

static uint8_t LCM_IsTwoByteCmd ( uint8_t cmd)
static

Definition at line 50 of file lcm_i2c.c.

References LCM_LAMP_ON, and LCM_SET_ADDR.

Referenced by LCM_I2C_OnRxData().

Variable Documentation

◆ s_i2c_cmd

volatile uint8_t s_i2c_cmd
static

Definition at line 37 of file lcm_i2c.c.

Referenced by LCM_I2C_OnRxData(), and LCM_I2C_ResetRx().

◆ s_i2c_rx_state

volatile LCM_I2C_RxState s_i2c_rx_state = LCM_I2C_WAIT_CMD
static

Definition at line 36 of file lcm_i2c.c.

Referenced by LCM_I2C_ArmRead(), LCM_I2C_OnRxData(), and LCM_I2C_ResetRx().

◆ s_i2c_tx_byte

volatile uint8_t s_i2c_tx_byte
static

Definition at line 38 of file lcm_i2c.c.

Referenced by LCM_I2C_ArmRead().

◆ s_i2c_tx_pending

volatile uint8_t s_i2c_tx_pending
static

Definition at line 39 of file lcm_i2c.c.

Referenced by LCM_I2C_ArmRead(), and LCM_I2C_ResetRx().