Usage And Implementation - XMOS SliceKit GPIO Gpio Example Applications

Table of Contents

Advertisement

SliceKit GPIO Example Applications
c_uartTX
message
int linear_interpolation(int adc_value)
Calculates temperatue based on linear interpolation.
This function has the following parameters:
adc_value
This function returns:
Returns linear interpolated Temperature value
int read_adc_value()
Read ADC value using I2C.
This function returns:
Returns ADC value

3.2.3 Usage and Implementation

The port declaration for the LEDs, Buttons, I2C and UART are declared as below. LEDs and Buttons
uses 4 bit ports, UART uses 1 bit ports both for Transmit and Receive and I2C uses 1 bit port for
SCL(I2c Clock) and SDA (I2C data).
# define CORE_NUM 1
# define BU T T O N _ P R E S S _ V A L U E 2
on stdcore [ CORE_NUM ] : buffered in port :1 p_rx =
on stdcore [ CORE_NUM ] : out port p_tx = XS1_PORT_1C ;
on stdcore [ CORE_NUM ]: port p_led = XS1_PORT_4A ;
on stdcore [ CORE_NUM ]: port p_button1 = XS1_PORT_4C ;
on stdcore [ CORE_NUM ]: struct r_i2c i2cOne = {
};
The app_manager API writes the configuration settings information to the ADC as shows below.
i 2 c _ m a s t e r _ w r i t e _ r e g (0 x28 , 0 x00 , i2c_register , 1 , i2cOne ) ; // Configure ADC by writing the
settings to register
The select statement in the app_manager API selects one of the three cases in it, checks if there
is IO event or timer event or any event on the Uart Receive pin. This statement monitors all the
events and executes which ever event is occurred first. The select statement in the applciation
is listed below. The statement checks if there is button press or availability of data on the Uart
Receive pin. If there is button press then it looks if the button state is same as even after 200msec.
If the buton state is same then it recognises as a valid push. If there is data on the Uart Receive
REV A
Channel to receive data from app Uart TX Thread
Buffer to store array of characters
int value read from ADC
XS1_PORT_1F ,
XS1_PORT_1B ,
1000
XS1_PORT_1G ;
10/24

Advertisement

Table of Contents
loading

This manual is also suitable for:

Slicekit

Table of Contents