コード例 #1
0
ファイル: main.c プロジェクト: dancollins/Quad-Rotor
int main(void) {
    init();
    int thrust = 0; // Holds thrust %age
    int old_thrust = 0; // Holds old thrust value.  Used to limit the number of bytes sent
    int checksum = 0; // checksum for outgoing serial data.  Integrity is important!

    while(1) {
        if (unlock) { // If the safety switch is active
            LATBbits.LATB5 = 1; // Green LED
            thrust = get_thrust(old_thrust);
            clear_bt_buf();
            __delay_ms(5);
        } else { // System is locked!
            LATBbits.LATB5 = 0; // Red LED
            clear_bt_buf();
            thrust = 0;
        }
        if (thrust != old_thrust) {
            old_thrust = thrust;
            uart_putChar('t', 2); // t for thrust, same as amarino
            uart_putChar(thrust, 2);

            checksum = ('t' ^ thrust); // Checksum is pretty simple for two bytes!
            
            uart_putChar(checksum, 2);
        }
    }

    return 0;
}
コード例 #2
0
ファイル: Retarget.c プロジェクト: samuelsilvaalves/Painel
/*----------------------------------------------------------------------------
  Write character to Serial Port
 *----------------------------------------------------------------------------*/
int sendchar (int c) {

  if (c == '\n')  {
  	uart_putChar (0, 0x0D);
	}
  uart_putChar (0, c);
  

  return (c);
}
コード例 #3
0
ファイル: uart.c プロジェクト: samuelsilvaalves/Painel
void uart_putString (int uart, char *s) 
{
  	while (*s != 0)
	{
		uart_putChar(uart,*s++); 
	}
}
コード例 #4
0
ファイル: main.c プロジェクト: dancollins/Quad-Rotor
void uart_putString(const char *s, char p){
    while(*s)
        uart_putChar(*s++, p); // Write a bunch of characters into the output buffer
}