Reely Tuning Experimental frame 209222 209222 Hoja De Datos

Los códigos de productos
209222
Descargar
Página de 4
Das Kommando selber ist dabei in ein Rahmenpaket das Kommando Identifikation, Kommando , 
Länge, Datenstruct (siehe oben) und crc Zeichen verpackt.  
Beispiel:  
Das Erweiterungsmodul sendet:  
<‚?‘>,< ‘C‘>,<länge>,<
ext_controldata>,<crc> 
Der Copter Antwortet dann mit:  
<‚?‘>,< ‘S‘>,<länge>,<
 ext_statusdata>,<crc> 
 
Eine Implementation kann wie folgt aussehen:  
void
 UART1_LOW__SendMessage(
char
 c,
char
 * msg, 
int
 len) 
{  
  
int
 i=0;         
  
char
 crc; 
   
  crc=0;   
 
    USART1_command_ready=1;  
    USART1_tx_command[0] = 
'?'
 
 
// Kommandoidentification (immer ‘?’) 
    USART1_tx_command[1] = c; 
 
 
// Kommando 
    USART1_tx_command[2] = (
char
)len; 
 
// Länge 
 
    i=3;  
    
while
(len>0) {    
      USART1_tx_command[i]=msg[i‐3]; 
 
// Daten incl. 8‐bit checksumme 
      crc=crc+USART1_tx_command[i]; 
      i++;                           
      len‐‐; 
    }                 
    USART1_tx_command[i]=crc; 
 
 
// crc Zeichen 
    USART1_tx_command_len=i+1;            
 
    UDR1 = USART1_tx_command[0];     
 
// Übertragung starten 
}   
 
void
 UART1_LOW__SendControl() 
{                             
  UART1_LOW__SendMessage(
'C'
,&EXT_controlData, 
sizeof
(EXT_controlData)); 
  
Als Komandobyte wird für das  
struct „ext_controlData“ wird  ‚C‘  verwendet.  
Für das  
struct „
ext_statusdata“ wird ‚S‘ verwendet. 
Zum Empfangen der Daten kann eine Implementierung z.B. wie folg aussehen:  
volatile
 
char
 rx_status=0;   
volatile
 
char
 rx_crc=0;  
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
 
// USART1 Receiver interrupt service routine
 
interrupt [USART1_RXC] 
void
 usart1_rx_isr(
void