/* * Intergalactical Positioning System (IPS) * Alfa 2 team * * TARGET */ /* Includes */ #include #include #include __USING_SYS const char err_msg[] = "ERROR"; /* PDU structure */ typedef struct PDU { unsigned short beacon_rssi[4]; unsigned short target_rssi; unsigned int pdu_type; unsigned char source; }; /* Variables */ int mask = 0x00; unsigned char * addr; unsigned char * prot; PDU * pdu; NIC * nic; Display * display; // To tests ;-) char * tmp; void blink() { CPU::out8(Machine::IO::PORTA, mask); } void blink_sent() { mask = mask ^ 0x04; blink(); } void send() { *addr = 0xFF; *prot = 0xDC; nic->send(*addr, *prot, pdu, sizeof(PDU)); blink_sent(); } int main() { /* Alloc some memory to structs and objects */ pdu = (PDU *) malloc(sizeof(PDU)); nic = new NIC(); display = new Display(); // To tests ;-) /* AVR compiler's bug, needs a malloc in chars!! */ addr = (unsigned char *) malloc(sizeof(char)); prot = (unsigned char *) malloc(sizeof(char)); // loucura... tmp = (char *) malloc(1); /* */ CPU::out8(Machine::IO::DDRA, 0xff); /* Infinite loop */ while(true) { /* Receives a packet */ send(); for(int i = 0; i < 0xffff; i++); for(int i = 0; i < 0xffff; i++); } }