Commit 4eba831a authored by Jake Read's avatar Jake Read

ring test all uart ports

parent 1441293c
......@@ -27,6 +27,8 @@
#define HARDWARE_ON_PERIPHERAL_C 0x2
#define HARDWARE_ON_PERIPHERAL_D 0x3
#define BAUD_SYSTEM 63018
/* USB PINS
USBDM PA24 USB
......
......@@ -73,46 +73,74 @@ void uarts_init(void){
// don't forget to also add the handler
NVIC_EnableIRQ(SERCOM0_0_IRQn);
NVIC_EnableIRQ(SERCOM0_2_IRQn);
// init rbs
rb_init(&up0rbrx);
rb_init(&up0rbtx);
// init uart
up0 = uart_new(SERCOM0, &PORT->Group[0], &up0rbrx, &up0rbtx, 5, 4);
MCLK->APBAMASK.reg |= MCLK_APBAMASK_SERCOM0;
uart_init(&up0, 7, SERCOM0_GCLK_ID_CORE, 63018, HARDWARE_ON_PERIPHERAL_D);
MCLK->APBAMASK.bit.SERCOM0_ = 1;
uart_init(&up0, 7, SERCOM0_GCLK_ID_CORE, BAUD_SYSTEM, HARDWARE_ON_PERIPHERAL_D);
// handlers
NVIC_EnableIRQ(SERCOM1_0_IRQn);
NVIC_EnableIRQ(SERCOM1_2_IRQn);
// init rbs
rb_init(&up1rbrx);
rb_init(&up1rbtx);
// init uart
up1 = uart_new(SERCOM1, &PORT->Group[0], &up1rbrx, &up1rbtx, 1, 0);
MCLK->APBAMASK.bit.SERCOM1_ = 1;
uart_init(&up1, 7, SERCOM1_GCLK_ID_CORE, BAUD_SYSTEM, HARDWARE_ON_PERIPHERAL_D);
// handlers
NVIC_EnableIRQ(SERCOM2_0_IRQn);
NVIC_EnableIRQ(SERCOM2_2_IRQn);
// init rbs
rb_init(&up2rbrx);
rb_init(&up2rbtx);
// init uart
up2 = uart_new(SERCOM2, &PORT->Group[0], &up2rbrx, &up2rbtx, 8, 9);
MCLK->APBBMASK.bit.SERCOM2_ = 1;
uart_init(&up2, 7, SERCOM2_GCLK_ID_CORE, BAUD_SYSTEM, HARDWARE_ON_PERIPHERAL_D);
// handlers
NVIC_EnableIRQ(SERCOM3_0_IRQn);
NVIC_EnableIRQ(SERCOM3_2_IRQn);
// init rbs
rb_init(&up3rbrx);
rb_init(&up3rbtx);
// init uart
up3 = uart_new(SERCOM3, &PORT->Group[0], &up3rbrx, &up3rbtx, 16, 17);
MCLK->APBBMASK.bit.SERCOM3_ = 1;
uart_init(&up3, 7, SERCOM3_GCLK_ID_CORE, BAUD_SYSTEM, HARDWARE_ON_PERIPHERAL_D);
// handlers
NVIC_EnableIRQ(SERCOM4_0_IRQn);
NVIC_EnableIRQ(SERCOM4_2_IRQn);
// init rbs
rb_init(&up4rbrx);
rb_init(&up4rbtx);
// init uart
up4 = uart_new(SERCOM4, &PORT->Group[0], &up4rbrx, &up4rbtx, 12, 13);
MCLK->APBDMASK.bit.SERCOM4_ = 1;
uart_init(&up4, 7, SERCOM4_GCLK_ID_CORE, BAUD_SYSTEM, HARDWARE_ON_PERIPHERAL_D);
// handlers
NVIC_EnableIRQ(SERCOM5_0_IRQn);
NVIC_EnableIRQ(SERCOM5_2_IRQn);
// init rbs
rb_init(&up5rbrx);
rb_init(&up5rbtx);
// uart init
up5 = uart_new(SERCOM5, &PORT->Group[0], &up5rbrx, &up5rbtx, 22, 23);
MCLK->APBDMASK.bit.SERCOM5_ = 1;
uart_init(&up5, 7, SERCOM5_GCLK_ID_CORE, BAUD_SYSTEM, HARDWARE_ON_PERIPHERAL_D);
// now pack all into ups
ups[0] = &up0;
......@@ -148,26 +176,43 @@ int main(void)
// a ticker to look for hangouts
SysTick_Config(8000000);
/* Replace with your application code */
uint8_t testUart[3] = {12,24,48};
while (1)
{
// waits for config to config
if(pCdc->IsConfigured(pCdc) != 0){
main_b_cdc_enable = true;
}
uint8_t testUart[3] = {12,24,48};
// if config is config, and port is opened
if(main_b_cdc_enable){
sam_ba_monitor_init(SAM_BA_INTERFACE_USBCDC);
// loops on this
while(1){
sam_ba_monitor_run();
for(int i = 0; i < NUM_UPS; i ++){
while(!rb_empty(up0.rbrx)){
uart_sendchar_buffered(&up0, rb_get(up0.rbrx));
}
while(!rb_empty(up0.rbrx)){
uart_sendchar_buffered(&up0, rb_get(up0.rbrx));
}
while(!rb_empty(up1.rbrx)){
uart_sendchar_buffered(&up1, rb_get(up1.rbrx));
}
while(!rb_empty(up2.rbrx)){
uart_sendchar_buffered(&up2, rb_get(up2.rbrx));
}
while(!rb_empty(up3.rbrx)){
uart_sendchar_buffered(&up3, rb_get(up3.rbrx));
}
while(!rb_empty(up4.rbrx)){
uart_sendchar_buffered(&up4, rb_get(up4.rbrx));
}
while(!rb_empty(up5.rbrx)){
uart_sendchar_buffered(&up5, rb_get(up5.rbrx));
}
//uart_sendchars_buffered(&up0, &testUart, 3);
// apaport loops
......@@ -206,4 +251,44 @@ void SERCOM0_0_Handler(void){
void SERCOM0_2_Handler(void){
uart_rxhandler(&up0);
}
void SERCOM1_0_Handler(void){
uart_txhandler(&up1);
}
void SERCOM1_2_Handler(void){
uart_rxhandler(&up1);
}
void SERCOM2_0_Handler(void){
uart_txhandler(&up2);
}
void SERCOM2_2_Handler(void){
uart_rxhandler(&up2);
}
void SERCOM3_0_Handler(void){
uart_txhandler(&up3);
}
void SERCOM3_2_Handler(void){
uart_rxhandler(&up3);
}
void SERCOM4_0_Handler(void){
uart_txhandler(&up4);
}
void SERCOM4_2_Handler(void){
uart_rxhandler(&up4);
}
void SERCOM5_0_Handler(void){
uart_txhandler(&up5);
}
void SERCOM5_2_Handler(void){
uart_rxhandler(&up5);
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment