FEEU Ultra-Low-Power Apollo Evaluation Kit Platform
Chapter 2 Using the Hardware
EEU-UG-2017120001-10
- 26 -
© Fujitsu Electronics Europe GmbH
Add
apolloiom.c
to your project and include
apolloiom.h
and
skamapollobase.h
in you C-file.
Following code gives an example how to use the IOM:
#incude "mcu.h"
#include "skamapollobase.h"
#include "apolloiom.h"
#include "apollogpio.h"
const stc_apolloiom_config_t stcIomConfig = {
IomInterfaceModeI2C, //use SPI mode
400000UL, //frequency
FALSE, //SPHA setting
FALSE, //SPOL setting
0, //WriteThreshold
60 //ReadThreshold
};
int main(void)
{
uint8_t b = 0xAA;
ApolloIOM_Configure(IOMSTR1,&stcIomConfig);
ApolloIOM_Enable(IOMSTR1);
ApolloGpio_GpioPullupEnable(BOARD_I2C_SCL_PIN,TRUE);
ApolloGpio_GpioPullupEnable(ARDUINO_SDA,TRUE);
ApolloGpio_GpioSelectPullup(ARDUINO_SCL,PullUp6K);
ApolloGpio_GpioSelectPullup(ARDUINO_SDA,PullUp6K);
ApolloGpio_GpioInputEnable(ARDUINO_SCL,TRUE);
ApolloGpio_GpioInputEnable(ARDUINO_SDA,TRUE);
ApolloGpio_GpioSelectFunction(ARDUINO_SCL _PIN,
ARDUINO_SCL_FUNC);
ApolloGpio_GpioSelectFunction(ARDUINO_SDA,
ARDUINO_SDA_FUNC);
// Writing 1 byte data for address 5, register 0x11
ApolloIom_I2CWriteRegister(IOMSTR1,0x05,0x11,&b,1);
// Reading 1 byte data for address 5, register 0x11
ApolloIom_I2CReadRegister(IOMSTR1,0x05,0x11,&b,1);
while(1)
{
__NOP();
}
}