-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from lf-lang/sdd-uart-update
Sdd uart update
- Loading branch information
Showing
5 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
Submodule flexpret
updated
8 files
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters