void broadcast_message(const char * message) { while(BusyUART2()); // Wait until previous transmission is finished putsUART2 ((unsigned int *)message); while(BusyUART2()); // Wait until previous transmission is finished while(BusyUART1()); // Wait until previous transmission is finished putsUART1 ((unsigned int *)message); while(BusyUART1()); // Wait until previous transmission is finished }
int16_t main(void) { int PWM_ON = '0'; int Sent_Byte = '0'; /* Configure the oscillator for the device */ ConfigureOscillator(); /* Initialize IO ports and peripherals */ InitApp(); /* TODO <INSERT USER APPLICATION CODE HERE> */ while(1) { if(ten_ms_flag == '11' && Sent_Byte == '0'){ Sent_Byte = '1'; while(BusyUART2()); putsUART2("50"); while(BusyUART2()); //OC1CON = 0x0005; } if (ten_ms_flag == '20' && PWM_ON == '0' ){ PWM_ON = '1'; OC1CON = 0x0005; } if(ten_ms_flag == '25'){ ten_ms_flag=0; PWM_ON = '0'; Sent_Byte = '0'; OC1CON = 0x0000; } } }
//General blocking UART send function, appends basic checksum unsigned char uartSend(unsigned char length, unsigned char *frame) { int i; unsigned char checksum = 0; while(BusyUART2()); WriteUART2(length); while(BusyUART2()); WriteUART2(~length); checksum = 0xFF; //send payload data for (i = 0; i < length; i++) { checksum += frame[i]; while(BusyUART2()); WriteUART2(frame[i]); } //Send Checksum Data while(BusyUART2()); WriteUART2(checksum); return 1; }
//Send command over UART to skinproc unsigned char sendTactileCommand(unsigned char length, unsigned char *frame) { static int i; static unsigned char val; tx_idx = frame[0]; for (i = 0; i < length; i++) { val = frame[i]; if (TACTILEUART) { while(BusyUART2()); WriteUART2(val); } } return 1; }
//General blocking UART send function, appends basic checksum unsigned char uartSend(unsigned char length, unsigned char *frame) { int i,j; // Calculate CRC and store at end of packet frame[length-1] = calculate_crc8(frame,length-1); LED_3=!LED_3; //send payload data for (i = 0; i < length; i++) { while(BusyUART2()); WriteUART2(frame[i]); for(j = 0; j < 200; j++); //Brief wait allows mbed to keep up } return 1; }