Commit e1e6cc21 authored by Jake Read's avatar Jake Read

working atsams70 uartport port

parent c139abb5
......@@ -8,8 +8,6 @@ Desktop="Desktop"
AutoSaveProject=1
UsedLibraryUrn="urn:adsk.eagle:library:371"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/transistor-power.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/BC832.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/atsam.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/fab.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/motors.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/power.lbr"
......@@ -20,19 +18,19 @@ UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/sparkfun/SparkFu
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/marekr/borkedlabs-passives.lbr"
[Win_1]
Type="Schematic Editor"
Type="Board Editor"
Loc="0 0 1919 1016"
State=1
Number=1
File="mkrouter.sch"
View="-37.3431 65.3764 184.551 208.023"
WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.2032 0.254 0.3048 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.1524"
Number=2
File="mkrouter.brd"
View="2.78266 15.3697 62.859 48.8939"
WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.254 0.3048 0.2032 0.1524"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6"
PadDrills=" 0.2 0.25 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6 0.3"
ViaDiameters=" 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2 1.3 0"
ViaDrills=" 0.2 0.25 0.3 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35"
HoleDrills=" 0.2 0.25 0.3 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35"
TextSizes=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778"
ViaDrills=" 0.2 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35 0.25 0.3"
HoleDrills=" 0.2 0.25 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35 0.3"
TextSizes=" 0.254 0.3048 0.4064 0.8128 1.27 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778 1.016 0.6096 1.4224 1.6764"
PolygonSpacings=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.27"
PolygonIsolates=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
MiterRadiuss=" 0.254 0.3175 0.635 1.27 2.54 1 2 2.5 5 7.5 10 0"
......@@ -41,14 +39,14 @@ DimensionExtWidths=" 0.127 0.254 0.1 0.13 0.26 0"
DimensionExtLengths=" 1.27 2.54 1 2 3 0"
DimensionExtOffsets=" 1.27 2.54 1 2 3 0"
SmdSizes=" 0.3048 0.1524 0.4064 0.2032 0.6096 0.3048 0.8128 0.4064 1.016 0.508 1.27 0.6604 1.4224 0.7112 1.6764 0.8128 1.778 0.9144 1.9304 0.9652 2.1844 1.0668 2.54 1.27 3.81 1.9304 5.08 2.54 6.4516 3.2512 1.27 0.635"
WireBend=0
WireBendSet=31
WireBend=4
WireBendSet=0
WireCap=1
MiterStyle=0
PadShape=0
ViaShape=1
PolygonPour=0
PolygonRank=0
PolygonRank=1
PolygonThermals=1
PolygonOrphans=0
TextRatio=8
......@@ -63,24 +61,22 @@ SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=91
Views=" 1: -37.3431 65.3764 184.551 208.023"
Sheet="1"
Layer=48
[Win_2]
Type="Board Editor"
Loc="0 0 1919 1016"
Type="Schematic Editor"
Loc="-8 -8 1911 1008"
State=1
Number=2
File="mkrouter.brd"
View="-17.6895 10.0557 68.8204 58.3304"
WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.254 0.3048 0.2032 0.1524"
Number=1
File="mkrouter.sch"
View="-38.8736 18.8994 146.038 137.772"
WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.2032 0.254 0.3048 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.1524"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.2 0.25 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6 0.3"
PadDrills=" 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6"
ViaDiameters=" 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2 1.3 0"
ViaDrills=" 0.2 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35 0.25 0.3"
HoleDrills=" 0.2 0.25 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35 0.3"
TextSizes=" 0.254 0.3048 0.4064 0.8128 1.27 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778 1.016 0.6096 1.4224 1.6764"
ViaDrills=" 0.2 0.25 0.3 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35"
HoleDrills=" 0.2 0.25 0.3 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35"
TextSizes=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778"
PolygonSpacings=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.27"
PolygonIsolates=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
MiterRadiuss=" 0.254 0.3175 0.635 1.27 2.54 1 2 2.5 5 7.5 10 0"
......@@ -89,14 +85,14 @@ DimensionExtWidths=" 0.127 0.254 0.1 0.13 0.26 0"
DimensionExtLengths=" 1.27 2.54 1 2 3 0"
DimensionExtOffsets=" 1.27 2.54 1 2 3 0"
SmdSizes=" 0.3048 0.1524 0.4064 0.2032 0.6096 0.3048 0.8128 0.4064 1.016 0.508 1.27 0.6604 1.4224 0.7112 1.6764 0.8128 1.778 0.9144 1.9304 0.9652 2.1844 1.0668 2.54 1.27 3.81 1.9304 5.08 2.54 6.4516 3.2512 1.27 0.635"
WireBend=4
WireBendSet=0
WireBend=0
WireBendSet=31
WireCap=1
MiterStyle=0
PadShape=0
ViaShape=1
PolygonPour=0
PolygonRank=1
PolygonRank=0
PolygonThermals=1
PolygonOrphans=0
TextRatio=8
......@@ -111,7 +107,9 @@ SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=48
Layer=91
Views=" 1: -38.8736 18.8994 146.038 137.772"
Sheet="1"
[Win_3]
Type="Control Panel"
......@@ -120,7 +118,7 @@ State=1
Number=0
[Desktop]
Screen="1920 1080"
Screen="3840 1080"
Window="Win_1"
Window="Win_2"
Window="Win_3"
......@@ -79,6 +79,8 @@ SUBDIRS := \
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../src/pin.c \
../src/ringbuffer.c \
../src/uartport.c \
../src/ASF/common/services/delay/sam/cycle_counter.c \
../src/ASF/common/services/clock/sams70/sysclk.c \
../src/ASF/sam/drivers/pmc/pmc.c \
......@@ -99,6 +101,8 @@ ASM_SRCS +=
OBJS += \
src/pin.o \
src/ringbuffer.o \
src/uartport.o \
src/ASF/common/services/delay/sam/cycle_counter.o \
src/ASF/common/services/clock/sams70/sysclk.o \
src/ASF/sam/drivers/pmc/pmc.o \
......@@ -112,6 +116,8 @@ src/main.o
OBJS_AS_ARGS += \
src/pin.o \
src/ringbuffer.o \
src/uartport.o \
src/ASF/common/services/delay/sam/cycle_counter.o \
src/ASF/common/services/clock/sams70/sysclk.o \
src/ASF/sam/drivers/pmc/pmc.o \
......@@ -125,6 +131,8 @@ src/main.o
C_DEPS += \
src/pin.d \
src/ringbuffer.d \
src/uartport.d \
src/ASF/common/services/delay/sam/cycle_counter.d \
src/ASF/common/services/clock/sams70/sysclk.d \
src/ASF/sam/drivers/pmc/pmc.d \
......@@ -138,6 +146,8 @@ src/main.d
C_DEPS_AS_ARGS += \
src/pin.d \
src/ringbuffer.d \
src/uartport.d \
src/ASF/common/services/delay/sam/cycle_counter.d \
src/ASF/common/services/clock/sams70/sysclk.d \
src/ASF/sam/drivers/pmc/pmc.d \
......@@ -182,6 +192,10 @@ LINKER_SCRIPT_DEP+= \
......
......@@ -4,6 +4,10 @@
src\pin.c
src\ringbuffer.c
src\uartport.c
src\ASF\common\services\delay\sam\cycle_counter.c
src\ASF\common\services\clock\sams70\sysclk.c
......
......@@ -52,11 +52,11 @@
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_XTAL
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_BYPASS
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_4M_RC
#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_8M_RC
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_8M_RC
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_12M_RC
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_XTAL
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_BYPASS
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLLACK
#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLLACK
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_UPLLCK
// ===== Processor Clock (HCLK) Prescaler Options (Fhclk = Fsys / (SYSCLK_PRES))
......@@ -70,11 +70,11 @@
//#define CONFIG_SYSCLK_PRES SYSCLK_PRES_3
// ===== System Clock (MCK) Division Options (Fmck = Fhclk / (SYSCLK_DIV))
#define CONFIG_SYSCLK_DIV 1
#define CONFIG_SYSCLK_DIV 2
// ===== PLL0 (A) Options (Fpll = (Fclk * PLL_mul) / PLL_div)
// Use mul and div effective values here.
#define CONFIG_PLL0_SOURCE PLL_SRC_MAINCK_XTAL
#define CONFIG_PLL0_SOURCE PLL_SRC_MAINCK_12M_RC
#define CONFIG_PLL0_MUL 25
#define CONFIG_PLL0_DIV 1
......
......@@ -10,10 +10,29 @@
#define HARDWARE_H_
#include "pin.h"
#include "ringbuffer.h"
#include "uartport.h"
// status lights
pin_t np1stlr;
pin_t np1stlg;
pin_t np1stlb;
pin_t np2stlr;
pin_t np2stlb;
pin_t np3stlr;
pin_t np3stlb;
pin_t np4stlr;
pin_t np4stlb;
pin_t np5stlr;
pin_t np5stlb;
pin_t *lights[] = {&np1stlr, &np1stlb, &np2stlr, &np2stlb, &np3stlr, &np3stlb, &np4stlr, &np4stlb, &np5stlr, &np5stlb};
// ringbuffers
ringbuffer_t np1rbrx;
ringbuffer_t np1rbtx;
// uartports
uartport_t up1;
uartport_t up2;
#endif /* HARDWARE_H_ */
\ No newline at end of file
......@@ -32,13 +32,59 @@
#include "hardware.h"
void messysetup(void){
void setupperipherals(void){
// kill the watchdog
WDT->WDT_MR = WDT_MR_WDDIS;
// start relevant peripheral clocks
PMC->PMC_PCER0 = 1 << ID_PIOA;
PMC->PMC_PCER0 = 1 << ID_PIOD;
// start uart clocks
PMC->PMC_PCER0 = 1 << ID_UART0;
//PMC->PMC_PCER0 = 1 << ID_UART1;
//PMC->PMC_PCER1 = 1 << (ID_UART2 - 32);
}
void setupinterrupts(void){
NVIC_DisableIRQ(UART0_IRQn);
NVIC_ClearPendingIRQ(UART0_IRQn);
NVIC_SetPriority(UART0_IRQn, 8);
NVIC_EnableIRQ(UART0_IRQn);
}
void lightsetup(void){
np1stlr = pin_new(PIOD, PIO_PER_P12);
pin_output(&np1stlr);
np1stlb = pin_new(PIOA, PIO_PER_P2);
pin_output(&np1stlb);
np2stlr = pin_new(PIOA, PIO_PER_P11);
pin_output(&np2stlr);
np2stlb = pin_new(PIOD, PIO_PER_P20);
pin_output(&np2stlb);
np3stlr = pin_new(PIOA, PIO_PER_P15);
pin_output(&np3stlr);
np3stlb = pin_new(PIOD, PIO_PER_P27);
pin_output(&np3stlb);
np4stlr = pin_new(PIOA, PIO_PER_P22);
pin_output(&np4stlr);
np4stlb = pin_new(PIOA, PIO_PER_P8);
pin_output(&np4stlb);
np5stlr = pin_new(PIOB, PIO_PER_P0);
pin_output(&np5stlr);
np5stlb = pin_new(PIOB, PIO_PER_P1);
pin_output(&np5stlb);
}
void lightstoggle(void){
for(int i = 0; i < 10; i++){
pin_toggle(lights[i]);
}
}
int main (void)
......@@ -47,28 +93,38 @@ int main (void)
// I think we can do 300, are at 150
board_init();
//NP1 (0)
// STLR PD12
// STLG PA3
// STLB PA2
setupperipherals();
setupinterrupts();
messysetup();
lightsetup();
rb_init(&np1rbrx);
rb_init(&np1rbtx);
// UP1 on UART0, RX 9 TX 10 on PIOA
up1 = uart_new(UART0, PIOA, 9, 10, &np1rbrx, &np1rbtx);
uart_init(&up1, 81);
/*
// UP2 on UART1, RX 5 TX 4 on PIOA
up2 = uart_new(UART1, PIOA, 5, 4, &np1rbrx, &np1rbtx);
uart_init(&up2, 81); // 81 for FTDI 115200 :|
*/
np1stlr = pin_new(PIOA, PIO_PER_P11);
pin_output(&np1stlr);
np1stlg = pin_new(PIOD, PIO_PER_P21);
pin_output(&np1stlg);
np1stlb = pin_new(PIOD, PIO_PER_P20);
pin_output(&np1stlb);
while(1){
pin_set(&np1stlr);
pin_set(&np1stlg);
pin_set(&np1stlb);
delay_ms(100);
pin_clear(&np1stlr);
pin_clear(&np1stlg);
pin_clear(&np1stlb);
delay_ms(100);
lightstoggle();
/*
uint8_t hello[] = {'h', 'e', 'l', 'l', 'o'};
if(!rb_empty(up1.rbrx)){
uart_sendchars_buffered(&up1, hello, 5);
uart_sendchar_buffered(&up1, rb_get(up1.rbrx));
}
*/
delay_ms(75);
}
}
\ No newline at end of file
}
void UART0_Handler(void){
uart_handler(&up1);
}
/*
* ringbuffer.c
*
* Created: 2/7/2018 11:39:44 AM
* Author: Jake
*/
#include "ringbuffer.h"
uint8_t rb_init(ringbuffer_t *rb){
rb->size = RINGBUFFER_SIZE; // stuck with this, due to not having malloc, wall of skill
//rb->buffer = malloc(size);
rb_reset(rb);
return 1;
}
uint8_t rb_reset(ringbuffer_t *rb){
if(rb){
rb->head = 0;
rb->tail = 0;
return 1;
} else {
return 0;
}
}
uint8_t rb_empty(ringbuffer_t *rb){
return (rb->head == rb->tail);
}
uint8_t rb_full(ringbuffer_t *rb){
return ((rb->head + 1) % rb->size) == rb->tail;
}
uint8_t rb_freespace(ringbuffer_t *rb){
if(rb->head >= rb->tail){
return rb->size - (rb->head - rb->tail);
} else {
return rb->tail - rb->head - 1;
}
}
uint8_t rb_putchar(ringbuffer_t *rb, uint8_t data){
rb->buffer[rb->head] = data;
rb->head = (rb->head + 1) % rb->size; // increment and loop about
return 1;
}
uint8_t rb_putdata(ringbuffer_t *rb, uint8_t *data, uint8_t size){
if(rb_freespace(rb) >= size){
return 0;
} else {
uint8_t i = 0;
while(i < size){
rb_putchar(rb, data[i]);
i ++;
}
return 1;
}
}
uint8_t rb_get(ringbuffer_t *rb){
uint8_t data = rb->buffer[rb->tail];
rb->tail = (rb->tail + 1) % rb->size;
return data;
}
/*
* ringbuffer.h
*
* Created: 2/7/2018 11:39:54 AM
* Author: Jake
*/
#ifndef RINGBUFFER_H_
#define RINGBUFFER_H_
/*
a ringbuffer,
s/o https://github.com/dhess/c-ringbuf
s/o https://embeddedartistry.com/blog/2017/4/6/circular-buffers-in-cc
s/o https://www.downtowndougbrown.com/2013/01/microcontrollers-interrupt-safe-ring-buffers/
*/
#include <stdlib.h> // for size_t
#include <asf.h>
#define RINGBUFFER_SIZE 256
typedef struct{
uint8_t buffer[256]; // static! big enough
size_t head;
size_t tail;
size_t size;
} ringbuffer_t;
uint8_t rb_init(ringbuffer_t *rb);
uint8_t rb_reset(ringbuffer_t *rb);
uint8_t rb_empty(ringbuffer_t *rb);
uint8_t rb_full(ringbuffer_t *rb);
uint8_t rb_freespace(ringbuffer_t *rb);
uint8_t rb_putchar(ringbuffer_t *rb, uint8_t data);
uint8_t rb_putdata(ringbuffer_t *rb, uint8_t *data, uint8_t size);
uint8_t rb_get(ringbuffer_t *rb);
#endif /* RINGBUFFER_H_ */
\ No newline at end of file
/*
* uartport.c
*
* Created: 2/22/2018 11:17:00 AM
* Author: Jake
*/
#include "uartport.h"
uartport_t uart_new(Uart *com, Pio *port, uint32_t pinrx, uint32_t pintx, ringbuffer_t *rbrx, ringbuffer_t *rbtx){
uartport_t uart;
uart.com = com;
uart.port = port;
uart.pinrx = pinrx;
uart.pinrx_bm = 1 << pinrx;
uart.pintx = pintx;
uart.pintx_bm = 1 << pintx;
uart.rbrx = rbrx;
uart.rbtx = rbtx;
return uart;
}
void uart_init(uartport_t *uart, uint32_t baud){
// PIO disable
uart->port->PIO_PDR = uart->pinrx_bm | uart->pintx_bm;
// abcdsr (global, do later)
// UART Registers
// mode register
uart->com->UART_MR = UART_MR_BRSRCCK_PERIPH_CLK | UART_MR_CHMODE_NORMAL | UART_MR_PAR_NO | UART_MR_FILTER_DISABLED;
// baud: freq ?
uart->com->UART_BRGR = baud;
// channel enable
uart->com->UART_CR = UART_CR_TXEN | UART_CR_RXEN;
// interrupt enable (rx only, tx on data)
uart->com->UART_IER = UART_IER_RXRDY;
rb_reset(uart->rbrx);
rb_reset(uart->rbtx);
}
void uart_sendchar_polled(uartport_t *uart, uint8_t data){
while(!(uart->com->UART_SR & UART_SR_TXRDY));
uart->com->UART_THR = data;
}
void uart_sendchar_buffered(uartport_t *uart, uint8_t data){
rb_putchar(uart->rbtx, data);
uart->com->UART_IER = UART_IER_TXRDY;
}
void uart_sendchars_buffered(uartport_t *uart, uint8_t *data, uint8_t length){
rb_putdata(uart->rbtx, data, length);
uart->com->UART_IER = UART_IER_TXRDY;
}
void uart_handler(uartport_t *uart){
if(uart->com->UART_SR & UART_SR_RXRDY){
uart_rxhandler(uart);
}
if((uart->com->UART_SR & UART_SR_TXRDY) && (uart->com->UART_IMR & UART_IMR_TXRDY)){
uart_txhandler(uart);
}
}
void uart_rxhandler(uartport_t *uart){
rb_putchar(uart->rbrx, uart->com->UART_RHR);
}
void uart_txhandler(uartport_t *uart){
if(!rb_empty(uart->rbtx)){
uart->com->UART_THR = rb_get(uart->rbtx); // transmit if non-empty
} else {
uart->com->UART_IDR = UART_IDR_TXRDY; // or turn this interrupt off
}
}
\ No newline at end of file
/*
* uartport.h
*
* Created: 2/22/2018 11:16:41 AM
* Author: Jake
*/
#ifndef UARTPORT_H_
#define UARTPORT_H_
#include <asf.h>
#include "ringbuffer.h"
#define UART_IS_PERIPHERAL_A 0x01
#define UART_IS_PERIPHERAL_B 0x02
#define UART_IS_PERIPHERAL_C 0x03
#define UART_IS_PERIPHERAL_D 0x04
typedef struct{
Uart *com;
Pio *port;
uint32_t pinrx;
uint32_t pinrx_bm;
uint32_t pintx;
uint32_t pintx_bm;
ringbuffer_t *rbrx;
ringbuffer_t *rbtx;
}uartport_t;
uartport_t uart_new(Uart *uart, Pio *port, uint32_t pinrx, uint32_t pintx, ringbuffer_t *rbrx, ringbuffer_t *rbtx);
void uart_init(uartport_t *uart, uint32_t baud);
void uart_sendchar_polled(uartport_t *uart, uint8_t data);
void uart_sendchar_buffered(uartport_t *uart, uint8_t data);
void uart_sendchars_buffered(uartport_t *uart, uint8_t *data, uint8_t length);
void uart_handler(uartport_t *uart);
void uart_rxhandler(uartport_t *uart);
void uart_txhandler(uartport_t *uart);
#endif /* UARTPORT_H_ */
\ No newline at end of file