FEEU Ultra-Low-Power Apollo Evaluation Kit Platform
Chapter 2 Using the Hardware
EEU-UG-2017120001-10
- 24 -
© 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 = {
IomInterfaceModeSpi, //use SPI mode
15000000UL, //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_GpioOutputEnable(ARDUINO_SS,TRUE);
CLEAR_GPIO(ARDUINO_SS); //set chipselect
//send one byte
ApolloIom_SpiWriteByte(IOMSTR1, 0, b, AM_HAL_IOM_RAW);
//read one byte
b = ApolloIom_SpiReadByte(IOMSTR1, 0, AM_HAL_IOM_RAW);
SET_GPIO(ARDUINO_SS); //clear chipselect
while(1)
{
__NOP();
}
}