SliceKit GPIO Example Applications
c_uartTX
Channel to receive data from app Uart TX Thread
message
Buffer to store array of characters
int linear_interpolation(int adc_value)
Calculates temperatue based on linear interpolation.
This function has the following parameters:
adc_value
int value read from ADC
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 BUTTON_PRESS_VALUE 2
on stdcore [ CORE_NUM ] : buffered in port :1 p_rx =
XS1_PORT_1G ;
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 = {
XS1_PORT_1F ,
XS1_PORT_1B ,
1000
};
The app_manager API writes the configuration settings information to the ADC as shows below.
i2c_master_write_reg (0 x28 , 0x00 , 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