background image

SliceKit GPIO Example Applications

9/24

};

3.2

COM Port Demo

3.2.1

Structure

All of the files required for operation are located in the

app_slicekit_simple_demo/src

directory.

The files that are need to be included for use of this component in an application are:

File

Description

common.h

Header file for API interfaces and Look up tables for thermistor. FIXME -

what about the uart

main.xc

Main file which implements the demo functionality

3.2.2

API

void app_manager(chanend c_uartTX,

chanend c_chanRX,
chanend c_process,
chanend c_end)

Polling uart RX and push button switches and send received commands to pro-
cess_data thread.

This function has the following parameters:

c_uartTX

Channel to Uart TX Thread

c_chanRX

Channel to Uart RX Thread

c_process

Channel to process data Thread

c_end

Channel to read data from process thread

void process_data(chanend c_process, chanend c_end)

process received data to see if received data is valid command or not Polling
switches to see for button press

This function has the following parameters:

c_process

Channel to receive data from app manager Thread

c_end

Channel to communicate to app manager thread

void uart_tx_string(chanend c_uartTX, unsigned char message[100])

Transmits byte by byte to the UART TX thread for an input string.

This function has the following parameters:

REV A

Содержание SliceKit

Страница 1: ...SliceKit GPIO Example Applications REV A Publication Date 2012 10 23 XMOS 2012 All Rights Reserved...

Страница 2: ...ommended Hardware 4 2 2 Example Applications 4 2 2 1 app_slicekit_simple_demo 4 2 2 2 app_slicekit_com_demo 4 3 Programming Guide 6 3 1 Simple Demo 6 3 1 1 Structure 6 3 1 2 API 6 3 1 3 Usage and Impl...

Страница 3: ...tor and buttons the I2C master xSOFTip component as well as various basic features of the xCORE processor Low level details of how the application is implemented are covered here with information abou...

Страница 4: ...ed with an external linearised thermistor circuit for temperature sensing simple code to print the recorded temperature to the XDE debug console on the press of one of the Slice Card buttons simple co...

Страница 5: ...SliceKit GPIO Example Applications 5 24 Cycles Through LEDs on button Press Displays temperature value and button press events on the terminal console of a host PC via the UART REV A...

Страница 6: ...implements the demo functionality 3 1 2 API void app_manager chanend c_uartTX chanend c_chanRX chanend c_process chanend c_end Polling uart RX and push button switches and send received commands to pr...

Страница 7: ...ADC The select statement in the app_manager API selects one of the two cases in it checks if there is IO event or timer event This statement monitors both the events and executes which ever event is...

Страница 8: ...s of ADC register using I2C read instruction and input the ADC value to linear interpolation function as shown below int linear_interpolation int adc_value int i 0 x1 y1 x2 y2 temper while adc_value T...

Страница 9: ...ton switches and send received commands to pro cess_data thread This function has the following parameters c_uartTX Channel to Uart TX Thread c_chanRX Channel to Uart RX Thread c_process Channel to pr...

Страница 10: ...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...

Страница 11: ...linear_interpolation adc_value printstr Temperature is printint linear_interpolation adc_value printstrln C break case uart_rx_get_byte_byref c_uartRX rxState buffer Command start if buffer IUF recei...

Страница 12: ...tTX n uart_tx_send_byte c_uartTX displays if command mode is activated else uart_tx_send_byte c_uartTX for int i 0 i 3 i uart_tx_send_byte c_uartTX cmd_rcvbuffer i if received dta is not c displays ba...

Страница 13: ...d j 0 skip 1 while skip 1 Send to process start select case uart_rx_get_byte_byref c_uartRX rxState buffer cmd_rcvbuffer j buffer if cmd_rcvbuffer j r skip 0 j 0 while cmd_rcvbuffer j r c_process cmd_...

Страница 14: ...data EXIT data INVALID uart_tx_string c_uartTX CONSOLE_MESSAGES 3 Displays COmmand Executed Message on Uart State machine switch data case EXIT Exit from command mode COMMAND_MODE 0 skip 0 uart_tx_str...

Страница 15: ...Value and Set LED 1 OFF p_led data p_led data 0x1 break case SET_LED_2 Read port Value and Set LED 2 ON p_led data p_led data 0 xD break case CLEAR_LED_2 Read port Value and Set LED 2 OFF p_led data p...

Страница 16: ...d data 0x4 break case SET_LED_4 Read port Value and Set LED 4 ON p_led data p_led data 0 x7 break case CLEAR_LED_4 Read port Value and Set LED 4 OFF p_led data p_led data 0x8 break case CLEAR_ALL sets...

Страница 17: ...sed c_end button if button BUTTON_1 Prints Button 1 is pressed on the Uart CONSOLE_MESSAG 4 9 1 uart_tx_string c_uartTX CONSOLE_M 4 button1_press 1 if button BUTTON_2 Prints Button 2 is pressed on Uar...

Страница 18: ...ng c_uartTX CONSOLE_MESSAGES 14 uart_tx_string c_uartTX CONSOLE_MESSAGES 7 uart_tx_string c_uartTX CONSOLE_MESSAGES 8 uart_tx_string c_uartTX CONSOLE_MESSAGES 9 uart_tx_string c_uartTX CONSOLE_MESSAGE...

Страница 19: ...ture value on the Uart adc_value read_adc_value data_arr 0 linear_interpolat adc_value uart_tx_string c_uartTX CONSOLE_MESSAGES 12 uart_tx_send_byte c_uartTX data_arr 0 10 0 uart_tx_send_byte c_uartTX...

Страница 20: ...ng c_uartTX CONSOLE_MESSAGES 2 break case CHK_BUTTONS Checks if button are pressed and displays on the Uart if button1_press CONSOLE_MESSAG 4 9 1 uart_tx_string c_uartTX CONSOLE_M 4 Displays Button 1...

Страница 21: ...1_press button2_press uart_tx_string c_uartTX CONSOLE_M 5 Displays No Buttons are pressed button1_press 0 button2_press 0 break if data EXIT Exits from command mode uart_tx_send_byte c_uartTX r uart_t...

Страница 22: ...artRX rxState buffer cmd_rcvbuffer j buffer if cmd_rcvbuffer j m cmd_rcvbuffer j M Checks if received data is M or m j uart_rx_get_byte_byref c_uartRX rxState buffer cmd_rcvbuffer j buffer if cmd_rcvb...

Страница 23: ...theread uart_tx_send_byte c_uartTX cmd_rcvbuffer j j cmd_rcvbuffer j 0 c_process cmd_rcvbuffer j for int inc 0 inc 20 inc Clears the command buffer cmd_rcvbuffer inc 0 j 0 break The process_data thre...

Страница 24: ...ormation or any particular implementation thereof is or will be free from any claims of infringement and again shall have no liability in relation to any such claims XMOS and the XMOS logo are registe...

Отзывы: