diff --git a/circuit/atsams70n-switch/atsams70n-switch.brd b/circuit/atsams70n-switch/atsams70n-switch.brd index e23bdb833a411b002ac2356ed2bbff5a5e11a51f..1898b5e2e249bd0c2e911e8335d99815d9267bf9 100644 --- a/circuit/atsams70n-switch/atsams70n-switch.brd +++ b/circuit/atsams70n-switch/atsams70n-switch.brd @@ -6,7 +6,7 @@ <setting alwaysvectorfont="no"/> <setting verticaltext="up"/> </settings> -<grid distance="20" unitdist="mil" unit="mil" style="lines" multiple="1" display="yes" altdistance="5" altunitdist="mil" altunit="mil"/> +<grid distance="10" unitdist="mil" unit="mil" style="lines" multiple="1" display="yes" altdistance="5" altunitdist="mil" altunit="mil"/> <layers> <layer number="1" name="Top" color="4" fill="1" visible="yes" active="yes"/> <layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/> @@ -205,8 +205,10 @@ cat</text> <text x="21.128990625" y="23.38705" size="0.8128" layer="21" font="vector" rot="R180">7</text> <text x="21.128990625" y="20.806409375" size="0.8128" layer="21" font="vector" rot="R180">5</text> <text x="21.128990625" y="18.22576875" size="0.8128" layer="21" font="vector" rot="R180">3</text> -<dimension x1="11.684" y1="63.5" x2="11.684" y2="14.224" x3="0" y3="38.862" textsize="1.778" layer="48"/> -<dimension x1="11.684" y1="63.5" x2="42.672" y2="63.5" x3="27.178" y3="70.104" textsize="1.778" layer="48"/> +<dimension x1="11.684" y1="63.754" x2="11.684" y2="14.732" x3="1.27" y3="39.243" textsize="1.778" layer="48"/> +<dimension x1="11.684" y1="63.754" x2="42.672" y2="63.754" x3="27.178" y3="69.342" textsize="1.778" layer="48"/> +<dimension x1="11.684" y1="63.754" x2="11.684" y2="66.802" x3="-1.778" y3="65.278" textsize="1.778" layer="48"/> +<dimension x1="11.684" y1="63.754" x2="8.636" y2="63.754" x3="10.16" y3="75.184" textsize="1.778" layer="48"/> </plain> <libraries> <library name="crystal" urn="urn:adsk.eagle:library:204"> diff --git a/circuit/atsams70n-switch/eagle.epf b/circuit/atsams70n-switch/eagle.epf index 06b42d0aab63a50e12398d5130e8b119b9fd0493..22ab89bcfbc47917791662e5f457eb6eb86467e3 100644 --- a/circuit/atsams70n-switch/eagle.epf +++ b/circuit/atsams70n-switch/eagle.epf @@ -36,7 +36,7 @@ Loc="0 0 1919 1039" State=1 Number=2 File="atsams70n-switch.sch" -View="-11.1752 -18.2176 175.417 87.9839" +View="62.9279 -21.864 249.52 84.3376" 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.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" @@ -75,7 +75,7 @@ ArcDirection=0 AddLevel=2 PadsSameType=0 Layer=91 -Views=" 1: -11.1752 -18.2176 175.417 87.9839" +Views=" 1: 62.9279 -21.864 249.52 84.3376" Sheet="1" [Win_2] @@ -84,7 +84,7 @@ Loc="0 0 1919 1039" State=1 Number=1 File="atsams70n-switch.brd" -View="30.9666 26.5371 36.7107 32.3263" +View="16.7928 5.66944 52.3586 41.5147" WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.254 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.2032 0.1524 0.3048" 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" diff --git a/embedded/README.md b/embedded/README.md index 643e82ef64c0ce90715148b27ed43614fb698193..9f8582854dfd3484df1fe358d074d674b745be66 100644 --- a/embedded/README.md +++ b/embedded/README.md @@ -4,6 +4,25 @@ // test at higher bitrates? // how to do big packet pushing? // better app layer - and make sure to clear space? + - towards timing measurement + +// status updates & lambda function + +// testing ... + - p1 -> hi when rx buffer non-empty + - p2 -> hi when packet handler has packet + - p3 -> hi when tx buffer non-empty + +# Results + +// do writeup + +In this screenshot, a falling edge on Channel 4 indicates an end of the main while() loop - so intervals between are packet processing and decision making. + +see captures saved ... 43us processing time, the rest is bitrate + +-> can we push bitrate by improving rx / tx interrupts? eliminate everything, try cranking past brgr 6 + [0:start][1:destination-msb:9][2:hopcount][3:source][4:#bytestotal][byte_5][byte_7]...[byte_n] 0-255 bytes diff --git a/embedded/atsams70-tinyrouter/.vs/atsams70-tinyrouter/v14/.atsuo b/embedded/atsams70-tinyrouter/.vs/atsams70-tinyrouter/v14/.atsuo index 2f3bfe9144f9f7d07078ae8e07fd188986711ea3..082ba7adaec048943c11ddd3c6d49720b54ec6ce 100644 Binary files a/embedded/atsams70-tinyrouter/.vs/atsams70-tinyrouter/v14/.atsuo and b/embedded/atsams70-tinyrouter/.vs/atsams70-tinyrouter/v14/.atsuo differ diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/atsams70-tinyrouter.cproj b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/atsams70-tinyrouter.cproj index 94e88c3f99a4ed783c22987dc608a456f84b4a78..37e466756a47261bcede3f4574bf4499eb5a99f0 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/atsams70-tinyrouter.cproj +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/atsams70-tinyrouter.cproj @@ -508,6 +508,9 @@ <Compile Include="src\ringbuffer.h"> <SubType>compile</SubType> </Compile> + <Compile Include="src\testpins.h"> + <SubType>compile</SubType> + </Compile> <Compile Include="src\tinyport.c"> <SubType>compile</SubType> </Compile> diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c index cb1c91595e5d5711605f37da3cb1f08b763e060b..231e973d5686aefcc3821fe17e142265c2c80158 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c @@ -30,6 +30,7 @@ */ #include <asf.h> #include "pin.h" +#include "testpins.h" #include "tinyport.h" #include "packet_handling.h" #include "ports.h" @@ -187,6 +188,7 @@ int main (void){ tp4 = tinyport_new(UART4, PIOD, PERIPHERAL_C, PIO_PER_P18, PIO_PER_P19, &p4rbrx, &p4rbtx, &p4lr, &p4lg, &p4lb); tp_init(&tp1); + UART2->UART_BRGR = 81; // manual set to FTDI speed tp_init(&tp2); tp_init(&tp3); tp_init(&tp4); @@ -207,6 +209,19 @@ int main (void){ ports[2] = &tp3; ports[3] = &tp4; + // test indicators + tstrx = pin_new(PIOD, PIO_PER_P8); + pin_output(&tstrx); + pin_clear(&tstrx); + tstpckt = pin_new(PIOD, PIO_PER_P6); + pin_output(&tstpckt); + pin_clear(&tstpckt); + tstclk = pin_new(PIOD, PIO_PER_P2); + pin_output(&tstclk); + pin_clear(&tsttx); + tsttx = pin_new(PIOD, PIO_PER_P4); + pin_output(&tsttx); + pin_clear(&tsttx); myAddress = MYADDRESS; @@ -219,13 +234,12 @@ int main (void){ packet_t packetlooper; while(1){ - + pin_set(&tstclk); // loop over ports to run packet deciphering... allows quick handling of RXINT w/ simpler rxhandler // each returns one packet at a time for(int i = 0; i < 4; i++){ tp_packetparser(ports[i]); } - for(int i = 0; i < 4; i++){ // loop over ports and check for packets, add packets to packet buffer if(ports[i]->haspacket){ @@ -239,6 +253,7 @@ int main (void){ packet_clean(&packetlooper); } } + pin_clear(&tstclk); delay_cycles(1); // one clock tick to relax interrupt scheduler } // end while } // end main diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h index dbe27eac0e68c0a632393d60b70ab64abd99e472..be973324fde032de6e1bdc415ce4651b4e4913aa 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h @@ -2,7 +2,7 @@ #define NODE_H_ #define MAX_HOPCOUNT 6 -#define MYADDRESS 1 +#define MYADDRESS 3 uint8_t LUT[1024][4]; uint8_t myAddress; diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ports.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ports.h index 1c976b76f5ca8daf6917e3f66b7d284b273cfb48..43e30b75c99e0307e649d7478fcddb7c444bff42 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ports.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ports.h @@ -48,5 +48,4 @@ pin_t p4lb; tinyport_t* ports[4]; - #endif /* PORTS_H_ */ \ No newline at end of file diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/testpins.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/testpins.h new file mode 100644 index 0000000000000000000000000000000000000000..8266da01ce1e7e83bb48dbbf64759e2547e5c79b --- /dev/null +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/testpins.h @@ -0,0 +1,20 @@ +/* + * testpins.h + * + * Created: 12/9/2017 11:34:09 PM + * Author: Jake + */ + + +#ifndef TESTPINS_H_ +#define TESTPINS_H_ + +#include "pin.h" + +// for testing +pin_t tstrx; // MKHeader P24, PD8 +pin_t tsttx; // MKHeader P20, PD4 +pin_t tstpckt; // MKHeader P22, PD6 +pin_t tstclk; // MKHeader P18, PD2 + +#endif /* TESTPINS_H_ */ \ No newline at end of file diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.c b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.c index 2e7086cab7ff71a7f7de996fb3916a3e443ca5f0..19e8e8547b94f99de17bbe2937878a93b9875a9a 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.c +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.c @@ -35,8 +35,9 @@ void tp_init(tinyport_t *tp){ // do abcdsr - a, b, c, d | 00, 01, 10, 11 // this is handled in global setup - tp->uart->UART_MR = UART_MR_BRSRCCK_PERIPH_CLK | UART_MR_CHMODE_NORMAL| UART_MR_PAR_NO | UART_MR_FILTER_DISABLED; - tp->uart->UART_BRGR = UART_BAUD_DIVIDER; + tp->uart->UART_MR = UART_MR_BRSRCCK_PERIPH_CLK | UART_MR_CHMODE_NORMAL | UART_MR_PAR_NO | UART_MR_FILTER_DISABLED; + tp->uart->UART_BRGR = UART_BAUD_DIVIDER; + tp->uart->UART_CR = UART_CR_TXEN | UART_CR_RXEN; tp->uart->UART_IER = UART_IER_RXRDY; @@ -66,6 +67,7 @@ void tp_rxhandler(tinyport_t *tp){ uint8_t data = tp->uart->UART_RHR; rb_putchar(tp->rbrx, data); pin_clear(tp->stlb); + pin_set(&tstrx); } void tp_packetparser(tinyport_t *tp){ @@ -107,6 +109,7 @@ void tp_packetparser(tinyport_t *tp){ tp->haspacket = TP_HAS_PACKET; // this data is final byte, we have packet, this will be last tick in loop tp->packetstate = TP_PACKETSTATE_OUTSIDE; // and we're outside again pin_set(tp->stlb); + pin_clear(&tstrx); } break; @@ -121,9 +124,11 @@ void tp_txhandler(tinyport_t *tp){ if(!rb_empty(tp->rbtx)){ tp->uart->UART_THR = rb_get(tp->rbtx); pin_clear(tp->stlg); + pin_set(&tsttx); } else { tp->uart->UART_IDR = UART_IER_TXRDY; // if nothing left to tx, turn isr off pin_set(tp->stlg); + pin_clear(&tsttx); // tricky, adding these increases transfer time... } //while(!(tp->uart->UART_SR & UART_SR_TXRDY)); // blocking } diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.h index 98809d3db97b2da00830288a278ce265c973f29d..9f51993a7ca433d55c3ac134049895b20a1d67b7 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.h @@ -48,11 +48,12 @@ // packet delimiters #define TP_DELIMITER_START 255 -#define UART_BAUD_DIVIDER 81 // 977: 9600 baud, 81: 115200, 10: 921600 +#define UART_BAUD_DIVIDER 6 // 977: 9600 baud, 81: 115200, 10: 921600: newclock: 63: 115200 #define RINGBUFFER_SIZE 1024 // in bytes, or 4 full length packets, have 384KBytes total in system #include "asf.h" #include "pin.h" +#include "testpins.h" #include "ringbuffer.h" #include "packet.h"