99 This file is distributed under BSD 3-Clause License.
1010
1111 (Usage)
12+ Copy the following 4 files and add to project.
13+ c_uart.h
14+ c_uart.c
15+ uart2.h
16+ uart2.c
17+
18+
1219 Hardware configration.
1320
1421 1. Use PSoC Creator, place "Communication > UART" device.
15- 2. Open a configure dialog.
22+ 2. Open a Configure dialog.
1623 3. Make sure the name is "UART_1".
1724 4. Set the baud rate and other parameters.
1825 5. Change to the "Advanced" tab and check "RX - ON Byte Received" and "TX - On TX Complete".
19- 6. Close this dialog.
26+ 6. Click OK button to close dialog.
2027 7. Place two "System > Interrupt" devices.
2128 8. Connect to tx_interrupt and rx_interrupt of UART.
2229 9. Change the names to "isr_UART_1_Tx" and "isr_UART_1_Rx" respectively.
6976/*! UART用設定
7077*/
7178#if !defined(MRBC_NUM_UART )
72- # define MRBC_NUM_UART 2
79+ # define MRBC_NUM_UART 1
7380#endif
7481
7582UART_HANDLE uh [MRBC_NUM_UART ];
@@ -95,7 +102,7 @@ UART_ISR( &uh[2], UART_3 );
95102 $uart = UART.new # automatic assign
96103 $uart = UART.new( num ) # 1 origin.
97104*/
98- static void c_uart_new (mrbc_vm * vm , mrbc_value v [], int argc )
105+ static void c_uart_new (struct VM * vm , mrbc_value v [], int argc )
99106{
100107 static int uart_counter = 0 ;
101108 int uart_num ;
@@ -133,7 +140,7 @@ static void c_uart_new(mrbc_vm *vm, mrbc_value v[], int argc)
133140 @return String Received data.
134141 @return Nil Not enough receive length.
135142*/
136- static void c_uart_read (mrbc_vm * vm , mrbc_value v [], int argc )
143+ static void c_uart_read (struct VM * vm , mrbc_value v [], int argc )
137144{
138145 mrbc_value ret ;
139146 UART_HANDLE * handle = * (UART_HANDLE * * )v -> instance -> data ;
@@ -161,7 +168,7 @@ static void c_uart_read(mrbc_vm *vm, mrbc_value v[], int argc)
161168
162169 @param s Write data.
163170*/
164- static void c_uart_write (mrbc_vm * vm , mrbc_value v [], int argc )
171+ static void c_uart_write (struct VM * vm , mrbc_value v [], int argc )
165172{
166173 UART_HANDLE * handle = * (UART_HANDLE * * )v -> instance -> data ;
167174
@@ -186,7 +193,7 @@ static void c_uart_write(mrbc_vm *vm, mrbc_value v[], int argc)
186193 @return String Received string.
187194 @return Nil Not enough receive length.
188195*/
189- static void c_uart_gets (mrbc_vm * vm , mrbc_value v [], int argc )
196+ static void c_uart_gets (struct VM * vm , mrbc_value v [], int argc )
190197{
191198 mrbc_value ret ;
192199 UART_HANDLE * handle = * (UART_HANDLE * * )v -> instance -> data ;
@@ -214,7 +221,7 @@ static void c_uart_gets(mrbc_vm *vm, mrbc_value v[], int argc)
214221
215222 $uart.clear_tx_buffer()
216223*/
217- static void c_uart_clear_tx_buffer (mrbc_vm * vm , mrbc_value v [], int argc )
224+ static void c_uart_clear_tx_buffer (struct VM * vm , mrbc_value v [], int argc )
218225{
219226 UART_HANDLE * handle = * (UART_HANDLE * * )v -> instance -> data ;
220227 uart_clear_tx_buffer ( handle );
@@ -226,7 +233,7 @@ static void c_uart_clear_tx_buffer(mrbc_vm *vm, mrbc_value v[], int argc)
226233
227234 $uart.clear_rx_buffer()
228235*/
229- static void c_uart_clear_rx_buffer (mrbc_vm * vm , mrbc_value v [], int argc )
236+ static void c_uart_clear_rx_buffer (struct VM * vm , mrbc_value v [], int argc )
230237{
231238 UART_HANDLE * handle = * (UART_HANDLE * * )v -> instance -> data ;
232239 uart_clear_rx_buffer ( handle );
0 commit comments