USB Device - Joystick/Mouse  1.0
Macros | Functions
STM324xG_EVAL_IOE_Exported_Functions

Macros

#define IOE_TimeoutUserCallback()   IOE_TIMEOUT
 Timeout user callback function. More...
 

Functions

uint8_t IOE_Config (void)
 Configuration and initialization functions. More...
 
uint8_t IOE_ITConfig (uint32_t IOE_ITSRC_Source)
 Configures The selected interrupts on the IO Expanders. More...
 
uint8_t IOE_WriteIOPin (uint8_t IO_Pin, IOE_BitValue_TypeDef BitVal)
 IO pins control functions. More...
 
uint8_t IOE_ReadIOPin (uint32_t IO_Pin)
 Returns the status of the selected input IO pin. More...
 
JOYState_TypeDef IOE_JoyStickGetState (void)
 Returns the current Joystick status. More...
 
TS_STATEIOE_TS_GetState (void)
 Touch Screen controller functions. More...
 
FlagStatus IOE_GetGITStatus (uint8_t DeviceAddr, uint8_t Global_IT)
 Interrupts Mangement functions. More...
 
uint8_t IOE_ClearGITPending (uint8_t DeviceAddr, uint8_t IO_IT)
 Clears the selected Global interrupt pending bit(s) More...
 
FlagStatus IOE_GetIOITStatus (uint8_t DeviceAddr, uint8_t IO_IT)
 Checks the status of the selected IO interrupt pending bit. More...
 
uint8_t IOE_ClearIOITPending (uint8_t DeviceAddr, uint8_t IO_IT)
 Clears the selected IO interrupt pending bit(s). More...
 
uint32_t IOE_TempSens_GetData (void)
 Temperature Sensor functions. More...
 
uint8_t IOE_IsOperational (uint8_t DeviceAddr)
 IO-Expander Control functions. More...
 
uint8_t IOE_Reset (uint8_t DeviceAddr)
 Resets the IO Expander by Software (SYS_CTRL1, RESET bit). More...
 
uint16_t IOE_ReadID (uint8_t DeviceAddr)
 Reads the selected device's ID. More...
 
uint8_t IOE_FnctCmd (uint8_t DeviceAddr, uint8_t Fct, FunctionalState NewState)
 Configures the selected IO Expander functionalities. More...
 
uint8_t IOE_IOPinConfig (uint8_t DeviceAddr, uint8_t IO_Pin, uint8_t Direction)
 Configures the selected pin direction (to be an input or an output) More...
 
uint8_t IOE_GITCmd (uint8_t DeviceAddr, FunctionalState NewState)
 Enables or disables the Global interrupt. More...
 
uint8_t IOE_GITConfig (uint8_t DeviceAddr, uint8_t Global_IT, FunctionalState NewState)
 Configures the selected source to generate or not a global interrupt. More...
 
uint8_t IOE_IOITConfig (uint8_t DeviceAddr, uint8_t IO_IT, FunctionalState NewState)
 Configures the selected pins to generate an interrupt or not. More...
 
uint8_t IOE_TS_Config (void)
 Low Layer functions. More...
 
uint8_t IOE_TempSens_Config (void)
 Configures and enables the Temperature sensor module. More...
 
uint8_t IOE_IOAFConfig (uint8_t DeviceAddr, uint8_t IO_Pin, FunctionalState NewState)
 Configures the selected pin to be in Alternate function or not. More...
 
uint8_t IOE_IOEdgeConfig (uint8_t DeviceAddr, uint8_t IO_Pin, uint8_t Edge)
 Configures the Edge for which a transition is detectable for the the selected pin. More...
 
uint8_t IOE_ITOutConfig (uint8_t Polarity, uint8_t Type)
 Configures the Interrupt line active state and format (level/edge) More...
 
uint8_t I2C_WriteDeviceRegister (uint8_t DeviceAddr, uint8_t RegisterAddr, uint8_t RegisterValue)
 Writes a value in a register of the device through I2C. More...
 
uint8_t I2C_ReadDeviceRegister (uint8_t DeviceAddr, uint8_t RegisterAddr)
 Reads a register of the device through I2C. More...
 
uint16_t I2C_ReadDataBuffer (uint8_t DeviceAddr, uint32_t RegisterAddr)
 Reads a buffer of 2 bytes from the device registers. More...
 

Detailed Description

Macro Definition Documentation

#define IOE_TimeoutUserCallback ( )    IOE_TIMEOUT

Timeout user callback function.

This function is called when a timeout condition occurs during communication with IO Expander. Only protoype of this function is decalred in IO Expander driver. Its implementation may be done into user application. This function may typically stop current operations and reset the I2C peripheral and IO Expander. To enable this function use uncomment the define USE_TIMEOUT_USER_CALLBACK at the top of this file.

Function Documentation

uint16_t I2C_ReadDataBuffer ( uint8_t  DeviceAddr,
uint32_t  RegisterAddr 
)

Reads a buffer of 2 bytes from the device registers.

Parameters
DeviceAddrThe address of the device, could be : IOE_1_ADDR or IOE_2_ADDR.
RegisterAddrThe target register address (between 00x and 0x24)
Return values
Apointer to the buffer containing the two returned bytes (in halfword).
uint8_t I2C_ReadDeviceRegister ( uint8_t  DeviceAddr,
uint8_t  RegisterAddr 
)

Reads a register of the device through I2C.

Parameters
DeviceAddrThe address of the device, could be : IOE_1_ADDR or IOE_2_ADDR.
RegisterAddrThe target register address (between 00x and 0x24)
Return values
Thevalue of the read register (0xAA if Timeout occurred)
uint8_t I2C_WriteDeviceRegister ( uint8_t  DeviceAddr,
uint8_t  RegisterAddr,
uint8_t  RegisterValue 
)

Writes a value in a register of the device through I2C.

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
RegisterAddrThe target register address
RegisterValueThe target register value to be written
Return values
IOE_OKif all operations are OK. Other value if error.
uint8_t IOE_ClearGITPending ( uint8_t  DeviceAddr,
uint8_t  Global_IT 
)

Clears the selected Global interrupt pending bit(s)

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
Global_ITthe Global interrupt to be cleared, could be any combination of the following values:
  • Global_IT_GPIO : All IOs interrupt
  • Global_IT_ADC : ADC interrupt
  • Global_IT_TEMP : Temperature Sensor interrupts
  • Global_IT_FE : Touch Screen Controller FIFO Error interrupt
  • Global_IT_FF : Touch Screen Controller FIFO Full interrupt
  • Global_IT_FOV : Touch Screen Controller FIFO Overrun interrupt
  • Global_IT_FTH : Touch Screen Controller FIFO Threshold interrupt
  • Global_IT_TOUCH : Touch Screen Controller Touch Detected interrupt
Return values
IOE_OKif all initializations are OK. Other value if error.
uint8_t IOE_ClearIOITPending ( uint8_t  DeviceAddr,
uint8_t  IO_IT 
)

Clears the selected IO interrupt pending bit(s).

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
IO_ITthe IO interrupt to be checked could be IO_ITx Where x can be from 0 to 7.
Return values
IOE_OKif all initializations are OK. Other value if error.
uint8_t IOE_Config ( void  )

Configuration and initialization functions.

Configuration and initialization functions.

Parameters
None
Return values
IOE_OKif all initializations done correctly. Other value if error.
uint8_t IOE_FnctCmd ( uint8_t  DeviceAddr,
uint8_t  Fct,
FunctionalState  NewState 
)

Configures the selected IO Expander functionalities.

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
IOE_TEMPSENS_FCTthe functions to be configured. could be any combination of the following values:
  • IOE_IO_FCT : IO function
  • IOE_TS_FCT : Touch Screen function
  • IOE_ADC_FCT : ADC function
  • IOE_TEMPSENS_FCT : Temperature Sensor function
Return values
IOE_OKif all initializations are OK. Other value if error.
FlagStatus IOE_GetGITStatus ( uint8_t  DeviceAddr,
uint8_t  Global_IT 
)

Interrupts Mangement functions.

Interrupts Mangement functions.

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
Global_ITthe Global interrupt source to be checked, could be:
  • Global_IT_GPIO : All IOs interrupt
  • Global_IT_ADC : ADC interrupt
  • Global_IT_TEMP : Temperature Sensor interrupts
  • Global_IT_FE : Touch Screen Controller FIFO Error interrupt
  • Global_IT_FF : Touch Screen Controller FIFO Full interrupt
  • Global_IT_FOV : Touch Screen Controller FIFO Overrun interrupt
  • Global_IT_FTH : Touch Screen Controller FIFO Threshold interrupt
  • Global_IT_TOUCH : Touch Screen Controller Touch Detected interrupt
Return values
Statusof the checked flag. Could be SET or RESET.
FlagStatus IOE_GetIOITStatus ( uint8_t  DeviceAddr,
uint8_t  IO_IT 
)

Checks the status of the selected IO interrupt pending bit.

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
IO_ITthe IO interrupt to be checked could be IO_ITx Where x can be from 0 to 7.
Return values
Statusof the checked flag. Could be SET or RESET.
uint8_t IOE_GITCmd ( uint8_t  DeviceAddr,
FunctionalState  NewState 
)

Enables or disables the Global interrupt.

Parameters
DeviceAddrThe address of the IOExpander, could be :I OE_1_ADDR or IOE_2_ADDR.
NewStatecould be ENABLE or DISABLE.
Return values
IOE_OKif all initializations are OK. Other value if error.
uint8_t IOE_GITConfig ( uint8_t  DeviceAddr,
uint8_t  Global_IT,
FunctionalState  NewState 
)

Configures the selected source to generate or not a global interrupt.

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
Global_ITthe interrupt source to be configured, could be:
  • Global_IT_GPIO : All IOs interrupt
  • Global_IT_ADC : ADC interrupt
  • Global_IT_TEMP : Temperature Sensor interrupts
  • Global_IT_FE : Touch Screen Controller FIFO Error interrupt
  • Global_IT_FF : Touch Screen Controller FIFO Full interrupt
  • Global_IT_FOV : Touch Screen Controller FIFO Overrun interrupt
  • Global_IT_FTH : Touch Screen Controller FIFO Threshold interrupt
  • Global_IT_TOUCH : Touch Screen Controller Touch Detected interrupt
Return values
IOE_OKif all initializations are OK. Other value if error.
uint8_t IOE_IOAFConfig ( uint8_t  DeviceAddr,
uint8_t  IO_Pin,
FunctionalState  NewState 
)

Configures the selected pin to be in Alternate function or not.

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
IO_PinIO_Pin_x, Where x can be from 0 to 7.
NewStateState of the AF for the selected pin, could be ENABLE or DISABLE.
Return values
IOE_OKif all initializations are OK. Other value if error.
uint8_t IOE_IOEdgeConfig ( uint8_t  DeviceAddr,
uint8_t  IO_Pin,
uint8_t  Edge 
)

Configures the Edge for which a transition is detectable for the the selected pin.

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
IO_PinIO_Pin_x, Where x can be from 0 to 7.
EdgeThe edge which will be detected. This parameter can be one or a a combination of following values: EDGE_FALLING and EDGE_RISING .
Return values
IOE_OKif all initializations are OK. Other value if error.
uint8_t IOE_IOITConfig ( uint8_t  DeviceAddr,
uint8_t  IO_IT,
FunctionalState  NewState 
)

Configures the selected pins to generate an interrupt or not.

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
IO_ITThe IO interrupt to be configured. This parameter could be any combination of the following values:
  • IO_IT_x: where x can be from 0 to 7.
NewStatecould be ENABLE or DISABLE.
Return values
IOE_OKif all initializations are OK. Other value if error.
uint8_t IOE_IOPinConfig ( uint8_t  DeviceAddr,
uint8_t  IO_Pin,
uint8_t  Direction 
)

Configures the selected pin direction (to be an input or an output)

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
IO_PinIO_Pin_x: Where x can be from 0 to 7.
Directioncould be Direction_IN or Direction_OUT.
Return values
IOE_OKif all initializations are OK. Other value if error.
uint8_t IOE_IsOperational ( uint8_t  DeviceAddr)

IO-Expander Control functions.

IO-Expander Control functions.

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
Return values
IOE_OKif IOE is operational. Other value if failure.
uint8_t IOE_ITConfig ( uint32_t  IOE_ITSRC_Source)

Configures The selected interrupts on the IO Expanders.

Parameters
IOE_ITSRC_Sourcethe source of the interrupts. Could be one or a combination of the following parameters:
  • IOE_ITSRC_JOYSTICK: Joystick IO intputs.
  • IOE_ITSRC_TSC: Touch Screen interrupts.
  • IOE_ITSRC_INMEMS: MEMS interrupt lines.
Return values
IOE_OKif all initializations are OK. Other value if error.
uint8_t IOE_ITOutConfig ( uint8_t  Polarity,
uint8_t  Type 
)

Configures the Interrupt line active state and format (level/edge)

Parameters
Polaritycould be
  • Polarity_Low: Interrupt line is active Low/Falling edge
  • Polarity_High: Interrupt line is active High/Rising edge
TypeInterrupt line activity type, could be one of the following values
  • Type_Level: Interrupt line is active in level model
  • Type_Edge: Interrupt line is active in edge model
Return values
IOE_OKif all initializations are OK. Other value if error.
JOYState_TypeDef IOE_JoyStickGetState ( void  )

Returns the current Joystick status.

Parameters
None
Return values
Thecode of the Joystick key pressed:
  • JOY_NONE
  • JOY_SEL
  • JOY_DOWN
  • JOY_LEFT
  • JOY_RIGHT
  • JOY_UP
uint16_t IOE_ReadID ( uint8_t  DeviceAddr)

Reads the selected device's ID.

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
Return values
TheDevice ID (two bytes).
uint8_t IOE_ReadIOPin ( uint32_t  IO_Pin)

Returns the status of the selected input IO pin.

Parameters
IO_PinThe input pin to be read. This parameter can be one of the following values:
  • MEMS_INT1_PIN: MEMS interrupt line 1.
  • MEMS_INT2_PIN: MEMS interrupt line 2.
  • JOY_IO_PINS: Joystick IO pins (use IOE_JoyStickGetState for these pins)
Return values
None
uint8_t IOE_Reset ( uint8_t  DeviceAddr)

Resets the IO Expander by Software (SYS_CTRL1, RESET bit).

Parameters
DeviceAddrThe address of the IOExpander, could be : IOE_1_ADDR or IOE_2_ADDR.
Return values
IOE_OKif all initializations are OK. Other value if error.
uint8_t IOE_TempSens_Config ( void  )

Configures and enables the Temperature sensor module.

Parameters
None
Return values
IOE_OKif all initializations are OK. Other value if error.
uint32_t IOE_TempSens_GetData ( void  )

Temperature Sensor functions.

Temperature Sensor functions.

Parameters
None
Return values
Thetemperature row value.
uint8_t IOE_TS_Config ( void  )

Low Layer functions.

Low Layer functions.

Parameters
None
Return values
IOE_OKif all initializations are OK. Other value if error.
TS_STATE* IOE_TS_GetState ( void  )

Touch Screen controller functions.

Touch Screen controller functions.

Parameters
None
Return values
Pointerto TS_STATE structure holding Touch Screen information.
uint8_t IOE_WriteIOPin ( uint8_t  IO_Pin,
IOE_BitValue_TypeDef  BitVal 
)

IO pins control functions.

IO pins control functions.

Parameters
IO_PinThe output pin to be set or reset. This parameter can be one of the following values:
  • AUDIO_RESET_PIN: Audio codec reset pin
  • MII_INT_PIN: Ethernet Phy MII interrupt pin
  • VBAT_DIV_PIN: Battery divider pin
BitValThe value to be set. This parameter can be one of the following values: BitSet or BitReset. See IOE_BitVal_TypeDef.
Return values
IOE_OKor PARAM_ERROR