void USART_ReceiveCmd(u8* strBuf,u8 strlen){ //variable for shift counter. u8 s; //Temp byte to be each checked and verify Enter symbol. u8 byteTemp; //Verify the Enter symbol and place the end sign for the string. for(s=0;s<strlen-1;s++){ byteTemp=USART_ReceiveByte(); if(byteTemp!=0x0D){ USART_WriteByte(byteTemp); strBuf[s]=byteTemp; } else{ strBuf[s]='\0'; break; } } //set the final end sign of the string buffer. strBuf[sizeof(strBuf)-1]='\0'; }
void TXE_Handler() { if(!fifo_is_empty(&Serial.fifo_output)) { USART_WriteByte(fifo_pop(&Serial.fifo_output)); } else { USART_DisableInterrupts(USART_IT_TXE); } }
void USART_WriteString(u8 string[]){ //variable for shift counter.(256 words limit). u8 s; //send the words until the end of line '\0'.(You can modify this function to meet 256 limit). for(s=0;string[s]!='\0';s++){ USART_WriteByte(string[s]); } }
unsigned char Modem_Call(TelNr nr) { nr.pos = 0; TCC0_wait_us(25); //NoNumber if(Modem_TelNr(_read, nr) == 11) return 1; //--------------------------------------------------DialNumber USART_WriteString("AT+FCLASS=8"); //EnablePhone USART_WriteByte(0x0D); //CR TCC0_wait_ms(100); //wait USART_WriteString("ATD+"); //CallHeader for(nr.pos= 0; ((nr.tel != 11) && (nr.pos < 16)); nr.pos++) { nr.tel= Modem_TelNr(_read, nr); if(nr.tel != 11) USART_WriteByte(nr.tel+48); } USART_WriteByte(0x0D); //CR //--------------------------------------------------Wait+HangUp LCD_WriteMyFont(16, 119, nr.id); TCC0_wait_sec(1); unsigned char point_pos = 0; for(nr.pos = 0; nr.pos < MO_HANG_UP_TIME; nr.pos++) { Watchdog_Restart(); if(point_pos > 5) { point_pos = 0; LCD_ClrSpace(16,119,2,41); } LCD_WriteMyFont(16, 123 + point_pos * 4, 22); //... point_pos++; TCC0_wait_sec(1); } //DisconnectCall USART_WriteString("ATH"); USART_WriteByte(0x0D); TCC0_wait_sec(1); LCD_ClrSpace(16,119,2,41); return 0; }
void TC_Handler() { if(!fifo_is_empty(&Serial.fifo_output)) { USART_EnableInterrupts(USART_IT_TXE); USART_WriteByte(fifo_pop(&Serial.fifo_output)); } else { Serial.State &= ~SERIAL_STATE_BUSY; } }
void CommQueueForTx(SerialData * ser, unsigned char data) { #ifdef X86GCC //ProcessDataChar(ser, data); #else //if (port->CharacterTransmitted!=0) /*if (((CommInterface*)(ser->ref))->port->CharacterTransmitted!=0) PORTE.OUTSET = PIN0_bm; else PORTE.OUTCLR = PIN0_bm; */ //USART_WriteByte(((CommInterface*)(ser->ref))->port, data)); USART_WriteByte(((CommInterface*)(ser->ref))->port, data); //PORTF.OUTSET = PIN7_bm; #endif //SerialByteTransmitComplete(ser); // byte successfully queued for transmission - get the next one }
void Modem_SendTest(void) { //PORTF.OUTSET= PIN4_bm; //RTS-Off PORTF.OUTCLR= PIN4_bm; TCC0_wait_ms(1); /*---------------------------------------------AT USART_WriteString("AT"); USART_WriteByte(0xD0); //CR //---------------------------------------------*/ //*---------------------------------------------AT USART_WriteByte('A'); //0x41 TCC0_wait_ms(1); USART_WriteByte('T'); //0x54 TCC0_wait_ms(1); USART_WriteByte(0x0D); //CR //---------------------------------------------*/ /*---------------------------------------------SMS USART_WriteString("AT+CMGF=1"); //TextMode USART_WriteByte(0x0D); //CR USART_WriteString("AT+CSMP=17,168,0,240"); //Parameters USART_WriteByte(0x0D); //CR TCC0_wait_ms(10); USART_WriteString("AT+CNMI=1,1,0,0,0"); USART_WriteByte(0x0D); //CR TCC0_wait_ms(10);LCD_Pin_WriteOK(1); USART_WriteString("AT+CMGW="); USART_WriteByte(0x22); //" USART_WriteString("+436802104231"); USART_WriteByte(0x22); //" USART_WriteString(">TEST"); USART_WriteByte(0x1A); //Ctrl-Z USART_WriteByte(0x0D); //CR TCC0_wait_ms(10); USART_WriteString("AT+CMSS=1"); USART_WriteByte(0x0D); //CR TCC0_wait_ms(10); USART_WriteString("AT+CMSS=2"); USART_WriteByte(0x0D); //CR TCC0_wait_ms(10); USART_WriteString("AT+CMSS=3"); USART_WriteByte(0x0D); //CR TCC0_wait_ms(10); USART_WriteString("AT+CMSS=4"); USART_WriteByte(0x0D); //CR TCC0_wait_ms(10); USART_WriteString("AT+CMSS=5"); USART_WriteByte(0x0D); //CR TCC0_wait_ms(10); USART_WriteString("AT+CMSS=6"); USART_WriteByte(0x0D); //CR //---------------------------------------------*/ /*---------------------------------------------PortSpeed USART_WriteString("AT+IPR=115200"); USART_WriteString(""); USART_WriteByte(0x0D); //CR //---------------------------------------------*/ /*---------------------------------------------SoftwareVersion USART_WriteString("AT+CGMR"); USART_WriteByte(0x0D); //CR //---------------------------------------------*/ /*---------------------------------------------ShutDown USART_WriteString("AT#SHDN"); USART_WriteByte(0x0D); //CR //---------------------------------------------*/ /*---------------------------------------------DialNumber USART_WriteString("AT+FCLASS=8"); //EnablePhone USART_WriteByte(0x0D); //CR TCC0_wait_sec(1); USART_WriteString("ATD+436802104231"); //Call USART_WriteByte(0x0D); //CR //---------------------------------------------*/ /*---------------------------------------------DialNumber - AT+FCLASS=8 - ATD+436802104231 USART_WriteByte('A'); USART_WriteByte('T'); USART_WriteByte('+'); USART_WriteByte('F'); USART_WriteByte('C'); USART_WriteByte('L'); USART_WriteByte('A'); USART_WriteByte('S'); USART_WriteByte('S'); USART_WriteByte('='); USART_WriteByte('8'); USART_WriteByte(0x0D); //CR TCC0_wait_sec(1); USART_WriteByte('A'); USART_WriteByte('T'); USART_WriteByte('D'); USART_WriteByte('+'); USART_WriteByte('4'); USART_WriteByte('3'); USART_WriteByte('6'); USART_WriteByte('8'); USART_WriteByte('0'); USART_WriteByte('2'); USART_WriteByte('1'); USART_WriteByte('0'); USART_WriteByte('4'); USART_WriteByte('2'); USART_WriteByte('3'); USART_WriteByte('1'); USART_WriteByte(0x0D); //CR //---------------------------------------------*/ TCC0_wait_ms(1); //PORTF.OUTSET= PIN4_bm; //RTS-Off }