33 UART class for Cypress PSoC5LP
44
55 <pre>
6- Copyright (C) 2018 Kyushu Institute of Technology.
7- Copyright (C) 2018 Shimane IT Open-Innovation Center.
6+ Copyright (C) 2018-2020 Kyushu Institute of Technology.
7+ Copyright (C) 2018-2020 Shimane IT Open-Innovation Center.
88
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-
1912 Hardware configration.
2013
2114 1. Use PSoC Creator, place "Communication > UART" device.
22- 2. Open a Configure dialog.
15+ 2. Open a configure dialog.
2316 3. Make sure the name is "UART_1".
2417 4. Set the baud rate and other parameters.
2518 5. Change to the "Advanced" tab and check "RX - ON Byte Received" and "TX - On TX Complete".
26- 6. Click OK button to close dialog.
19+ 6. Close this dialog.
2720 7. Place two "System > Interrupt" devices.
2821 8. Connect to tx_interrupt and rx_interrupt of UART.
2922 9. Change the names to "isr_UART_1_Tx" and "isr_UART_1_Rx" respectively.
6356#include <stdint.h>
6457#include <project.h> // auto generated by PSoC Creator.
6558
66- #include "value.h"
67- #include "alloc.h"
68- #include "static.h"
69- #include "class.h"
70- #include "c_string.h"
71-
7259#include "uart2.h"
60+ #include "mrubyc.h"
7361
7462
7563//================================================================
@@ -102,7 +90,7 @@ UART_ISR( &uh[2], UART_3 );
10290 $uart = UART.new # automatic assign
10391 $uart = UART.new( num ) # 1 origin.
10492*/
105- static void c_uart_new (struct VM * vm , mrbc_value v [], int argc )
93+ static void c_uart_new (mrbc_vm * vm , mrbc_value v [], int argc )
10694{
10795 static int uart_counter = 0 ;
10896 int uart_num ;
@@ -140,7 +128,7 @@ static void c_uart_new(struct VM *vm, mrbc_value v[], int argc)
140128 @return String Received data.
141129 @return Nil Not enough receive length.
142130*/
143- static void c_uart_read (struct VM * vm , mrbc_value v [], int argc )
131+ static void c_uart_read (mrbc_vm * vm , mrbc_value v [], int argc )
144132{
145133 mrbc_value ret ;
146134 UART_HANDLE * handle = * (UART_HANDLE * * )v -> instance -> data ;
@@ -168,7 +156,7 @@ static void c_uart_read(struct VM *vm, mrbc_value v[], int argc)
168156
169157 @param s Write data.
170158*/
171- static void c_uart_write (struct VM * vm , mrbc_value v [], int argc )
159+ static void c_uart_write (mrbc_vm * vm , mrbc_value v [], int argc )
172160{
173161 UART_HANDLE * handle = * (UART_HANDLE * * )v -> instance -> data ;
174162
@@ -193,7 +181,7 @@ static void c_uart_write(struct VM *vm, mrbc_value v[], int argc)
193181 @return String Received string.
194182 @return Nil Not enough receive length.
195183*/
196- static void c_uart_gets (struct VM * vm , mrbc_value v [], int argc )
184+ static void c_uart_gets (mrbc_vm * vm , mrbc_value v [], int argc )
197185{
198186 mrbc_value ret ;
199187 UART_HANDLE * handle = * (UART_HANDLE * * )v -> instance -> data ;
@@ -221,7 +209,7 @@ static void c_uart_gets(struct VM *vm, mrbc_value v[], int argc)
221209
222210 $uart.clear_tx_buffer()
223211*/
224- static void c_uart_clear_tx_buffer (struct VM * vm , mrbc_value v [], int argc )
212+ static void c_uart_clear_tx_buffer (mrbc_vm * vm , mrbc_value v [], int argc )
225213{
226214 UART_HANDLE * handle = * (UART_HANDLE * * )v -> instance -> data ;
227215 uart_clear_tx_buffer ( handle );
@@ -233,7 +221,7 @@ static void c_uart_clear_tx_buffer(struct VM *vm, mrbc_value v[], int argc)
233221
234222 $uart.clear_rx_buffer()
235223*/
236- static void c_uart_clear_rx_buffer (struct VM * vm , mrbc_value v [], int argc )
224+ static void c_uart_clear_rx_buffer (mrbc_vm * vm , mrbc_value v [], int argc )
237225{
238226 UART_HANDLE * handle = * (UART_HANDLE * * )v -> instance -> data ;
239227 uart_clear_rx_buffer ( handle );
0 commit comments