Skip to content

Commit

Permalink
Merge pull request #16 from lf-lang/sdd-uart-update
Browse files Browse the repository at this point in the history
Sdd uart update
  • Loading branch information
erlingrj authored Feb 10, 2023
2 parents e2863e3 + 74e335d commit 6c57087
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 2 deletions.
Empty file added programs/TCRS/sddUart/README.md
Empty file.
32 changes: 32 additions & 0 deletions programs/TCRS/sddUart/receive.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

#include <flexpret.h>
#include <sdd_uart.h>
#include <flexpret_stdio.h>

#define RX_PIN 0
#define RX_BAUD 115200
#define RX_PORT 1

static sdd_uart_config_t uart ={.initialized = false};
void * t1(void * arg) {
uart.pin = RX_PIN;
uart.baud = RX_BAUD;
uart.port = RX_PORT;
uart.buf_size = 8;
sdd_uart_rx_run(&uart);
}

void main(void) {
if(read_coreid() == 0) {
thread_t tid1 = 1;
int errno = thread_map(true, &tid1, t1, 0);
assert(errno == 0);
while(!uart.initialized) {};
char byte;
while(true) {
if (sdd_uart_rx_receive(&uart, &byte) == FP_SUCCESS) {
print_int(byte);
}
}
}
}
30 changes: 30 additions & 0 deletions programs/TCRS/sddUart/transmit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <flexpret_stdio.h>
#include <flexpret_io.h>
#include <flexpret_lock.h>
#include <flexpret_thread.h>
#include <flexpret_printer.h>

#define UART_PIN 0
#define UART_BAUD 270000
#define UART_PORT 1


void* t1(void * arg) {
fp_printer_config_t cfg = {
.port=UART_PORT,
.pin=UART_PIN,
.baudrate=UART_BAUD
};
fp_printer_run(&cfg);
}

void main(void) {
if(read_coreid() == 0) {
thread_t tid = 1;

int errno = thread_map(true, &tid, t1, 0);
assert(errno == 0);

fp_printer_str("Hello World!\n");
}
}
12 changes: 11 additions & 1 deletion programs/print/print_intercore.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@
#include <flexpret_assert.h>
#include <flexpret_noc.h>

#define STDIO_UART_PIN 0
#define STDIO_UART_BAUD 115200
#define STDIO_UART_PORT 1

void* t1(void* arg) {
fp_printer_run();
fp_printer_config_t cfg = {
.baudrate = STDIO_UART_BAUD,
.pin = STDIO_UART_PIN,
.port = STDIO_UART_PORT
};

fp_printer_run(&cfg);
}

void *t2(void *arg) {
Expand Down

0 comments on commit 6c57087

Please sign in to comment.