52 #define SESSION_REQ_TIMEOUT 10000
59 typedef uint32_t ptype_t;
66 ptype_t get_packet_type(packet_t * p
__attribute__((unused))) {
67 return MAX_PACKET_TYPE;
70 typedef uint32_t session_id_t;
75 uint32_t get_time(
void) {
76 static volatile int32_t cur_time = 0;
82 #define random_short_addr() (*MACA_RANDOM & ones(sizeof(uint16_t)*8))
84 void build_session_req(
volatile packet_t *p) {
85 static uint8_t count = 0;
86 p->length = 4; p->offset = 0;
95 static volatile int time = 0;
98 if((get_time() - time) > SESSION_REQ_TIMEOUT) {
100 if((p = get_free_packet())) {
101 build_session_req(p);
108 session_id_t open_session(uint16_t addr __attribute((unused))) {
return 0; }
112 volatile packet_t *p;
115 uint16_t addr, my_addr;
118 pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
120 uart_init(INC, MOD, SAMP);
130 my_addr = random_short_addr();
133 *GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
134 gpio_pad_dir_set( 1ULL << 44 );
136 print_welcome(
"Packet error test");
143 if((p = rx_packet())) {
147 type = get_packet_type((packet_t *) p);
151 if(addr == my_addr) {
152 my_addr = random_short_addr();
153 printf(
"DUP addr received, changing to new addr 0x%x02\n\r",my_addr);
157 if(type == PACKET_SESS_REQ) {
159 sesid = open_session(addr);
162 session_req(my_addr);