📄 cdr18uat.c
字号:
/* simple verification... avoid some syncronization problems */ if (RX_Buffer[0]!='R') { u8_dr18_NbDataRX = 0; } }}/* p_dr18_UARTSearchCommand *//* FUNCTIONAL DESCRIPTION * * This function stop the ring * * INTERFACE DECLARATION */void p_dr18_UARTRingOFF(void){ p_os10_PutMsgInfo(FTMI_ID,0, PS_RINGER_OFF_IND, 1); }/* p_dr18_UARTRingOFF *//* FUNCTIONAL DESCRIPTION * * This function start the ring * * INTERFACE DECLARATION */void p_dr18_UARTRingON(void){ /*I need to send two times the message RINGER_ON because the SMS * doesn't care of the first message*/ /*only one ring*/ p_os10_PutMsgInfo(FTMI_ID,0, PS_RINGER_ON_IND, 1);// p_os10_PutMsgInfo(FTMI_ID,0, PS_RINGER_OFF_IND, 0);// p_os10_PutMsgInfo(FTMI_ID,0, PS_RINGER_ON_IND, 0);}/* p_dr18_UARTRingON */#endif /* (NR_IOM_LINES>0) */#ifdef UART/* FUNCTIONAL DESCRIPTION * * This function transmits a sequence of bytes. * It does not wait for completion, so the buffer should not be * written to immediately after invokation. To be sure, p_dr18_UARTTxWait() * may be called. * However, only one asynchronous transmission may be scheduled. * So it might be possible that an invocation has to wait for * completion of a previous one. * * PARAMETER * buf buffer of bytes to transmit * len number of bytes to transmit (0..254) * * INTERFACE DECLARATION */void p_dr18_UARTTx(u8 *pu8_Buf, u8 u8_Len){ p_dr18_UARTTxWait(); /* assert: queue is empty */ pu8_dr18_UARTTxJob= pu8_Buf; /* queue buffer */ G_u8_dr08_UARTTxBusy= 1; /* flag for the outside */ /* No extra interrupt is used as in the previous implementation. */ u8_dr18_UARTTxLen= u8_Len; /* store number of TI ints */ VOLATILE(sys2_UART.thr,u8) = *pu8_dr18_UARTTxJob++;} /* p_dr18_UARTTx *//* FUNCTIONAL DESCRIPTION * * This function receives and returns a single byte. * * If currently no byte is present, the function waits. * The return type is char as the prototype has to be * compatible to _getkey. * * PARAMETER * return the byte received * * INTERFACE DECLARATION */char p_dr18_UARTRcv(void) /* == _getkey() */{ u8 u8_Byt; while(!VOLATILE(G_u8_dr08_UARTRcvFlag,u8)) { /* do nothing, wait for UART interrupt */ } SYS5_DISABLE_IRQ;#ifdef DR18_RX_BUFFER_SIZE u16_dr18_RxBufferReadIndex = (u16_dr18_RxBufferReadIndex + 1) % DR18_RX_BUFFER_SIZE; u8_Byt= u8_dr18_RxBuffer[u16_dr18_RxBufferReadIndex]; if (DR18_RX_BUFFER_EMPTY) { /* Backwards compatible to old kbhit */ G_u8_dr08_UARTRcvFlag= 0; }#else u8_Byt= u8_dr18_UARTRcvByte; G_u8_dr08_UARTRcvFlag= 0;#endif /* Enable Interrupt */ SYS5_ENABLE_IRQ; return u8_Byt;} /* p_dr18_UARTRcv *//* FUNCTIONAL DESCRIPTION * * This function waits for completion of the current transmission. * * INTERFACE DECLARATION */void p_dr18_UARTTxWait(void){ while(VOLATILE(u8_dr18_UARTTxLen,u8)) { /* do nothing */ }} /* p_dr18_UARTTxWait */void p_dr18_UARTInterrupt(void) /* For documentation purpose, the following obsolete implementation is NOT removed. */// if (TI) /* transmitted indication */// {// TI= 0;// if(u8_dr18_UARTTxLen>1) /* transmit byte */// {// u8_dr18_UARTTxLen--;// S0BUF= *pu8_dr18_UARTTxJob++;// }// else /* just confirmed the last byte */// {// u8_dr18_UARTTxLen= 0;// G_u8_dr08_UARTTxBusy= 0; /* flag for the outside */ // }// // }// if (RI) /* received indication */// {// RI= 0;// u8_dr18_UARTRcvByte= S0BUF;// G_u8_dr08_UARTRcvFlag= 1;// }{ u8 u8_IIR = VOLATILE(sys2_UART.iir,u8); u8 u8_LSR; do { u8_IIR = u8_IIR & SYS2_UART_IIR_IID_MASK; switch (u8_IIR) { case SYS2_UART_IIR_IID_P4: //modem interrupt break; case SYS2_UART_IIR_IID_P3: //Transmit data register empty /* more data to send ? */ if(u8_dr18_UARTTxLen>1) { u8_dr18_UARTTxLen--; VOLATILE(sys2_UART.thr,u8) = *pu8_dr18_UARTTxJob++; } else /* just confirmed the last byte */ { u8_dr18_UARTTxLen= 0; G_u8_dr08_UARTTxBusy= 0; } break; case SYS2_UART_IIR_IID_P2A: //Receive data available#ifdef DR18_RX_BUFFER_SIZE if (DR18_RX_BUFFER_FULL) { /* Buffer overflow, discard oldest unread character */ u16_dr18_RxBufferReadIndex = (u16_dr18_RxBufferReadIndex + 1)% DR18_RX_BUFFER_SIZE; } u16_dr18_RxBufferWriteIndex = (u16_dr18_RxBufferWriteIndex + 1)% DR18_RX_BUFFER_SIZE; u8_dr18_RxBuffer[u16_dr18_RxBufferWriteIndex] = VOLATILE(sys2_UART.rbr,u8);#endif u8_dr18_UARTRcvByte= VOLATILE(sys2_UART.rbr,u8); G_u8_dr08_UARTRcvFlag= 1; #ifdef DATA_APP_DEMO /* For the double slot demonstrator, UART is used to communicate with the computer. */ p_hm17_RxDemoDataFromUART(u8_dr18_UARTRcvByte);#endif break; case SYS2_UART_IIR_IID_P2B: //FIFO timeout break; case SYS2_UART_IIR_IID_P1: //Receive line status u8_LSR = VOLATILE(sys2_UART.lsr,u8); break; default: break; } u8_IIR = VOLATILE(sys2_UART.iir,u8); } while ((u8_IIR & SYS2_UART_IIR_PENDING)==0); }#endif /* UART */#if (NR_IOM_LINES>0)/* FUNCTIONAL DESCRIPTION * * This function is the UART interrupt handler. * * INTERFACE DECLARATION */void p_dr18_UARTInterrupt(void){ u16 IIR = 0x0000; IIR = VOLATILE(sys2_UART.iir,u8); do { IIR = IIR & 0x07; IIR = IIR >> 1; switch (IIR) { case 0: //modem interrupt break; case 1: //Transmit data empty switch (u8_dr18_CmdSend) { case HKOF: //send next data HKOF u8_dr18_NbDataSend++; if(u8_dr18_NbDataSend < DR18_NB_DATA_SEND) { VOLATILE(sys2_UART.thr,u8) = tab_HKOF[u8_dr18_NbDataSend]; } else { u8_dr18_NbDataSend = 0; u8_dr18_CmdSend = 0; if(u8_dr18_CmdRcvd == RGOF) { delayUs(1000000); p_dr18_UARTDial(); } } break; case HKON: u8_dr18_CmdRcvd = RGOF; u8_dr18_NbDataSend++; if(u8_dr18_NbDataSend < DR18_NB_DATA_SEND) { VOLATILE(sys2_UART.thr,u8) = tab_HKON[u8_dr18_NbDataSend]; } else { u8_dr18_NbDataSend = 0; u8_dr18_CmdSend = 0; } break; case DIAL: u8_dr18_NbDataSend++; if(u8_dr18_NbDataSend < DR18_NB_DATA_SEND_DIAL) { VOLATILE(sys2_UART.thr,u8) = tab_DIAL[u8_dr18_NbDataSend]; } else { u8_dr18_NbDataSend = 0; u8_dr18_CmdSend = 0; } break; default: break; } break; // break; ?? case 2: //Receive data available RX_Buffer[u8_dr18_NbDataRX] = VOLATILE(sys2_UART.rbr,u8); if (u8_dr18_NbDataRX < DR18_NB_DATA_BUFFER) u8_dr18_NbDataRX++; else u8_dr18_NbDataRX=0; p_dr18_UARTSearchCommand(); break; case 3: //Receive line status IIR = VOLATILE(sys2_UART.lsr,u8); break; case 6: //FIFO timeout break; default: break; } IIR = VOLATILE(sys2_UART.iir,u8); } while ((IIR & 0x01)==0);} /* p_dr18_UARTInterrupt *//* ####################################################################### *//* FUNCTIONAL DESCRIPTION * * This function initializes the IOM driver to * * INTERFACE DECLARATION */void p_dr18_IOMInit(u8 u8_Master){ //configuration of GPIO in mode IOM bus VOLATILE(sys2_GPIO.mux1,u32) |= SYS2_GPIO1_IOM_SEL; //selction of a clock divider in function of the speed of arm clock VOLATILE(sys0_SCU.clk_div,u32) |= 0x00000100; //activation of the IOM bus VOLATILE(sys0_SCU.pb_pcon_on,u32) |= SYS0_SCU_IPINT_POWER_MASK; /**** Start configuration of the IOM register ********/ VOLATILE(sys2_IPINT.global,u32) = 0x0000; if(u8_Master == 1) { VOLATILE(sys2_IPINT.ipintcntl0,u32) = SYS2_IP_MASTER | SYS2_IP_IOCK | SYS2_IP_IOD_PUSH_PULL_ALWAYS | SYS2_IP_FSTYP_LFS | SYS2_IP_PCM2048khz; } else { VOLATILE(sys2_IPINT.ipintcntl0,u32) = SYS2_IP_IOCK | SYS2_IP_IOD_PUSH_PULL_ALWAYS | SYS2_IP_FSTYP_LFS | SYS2_IP_PCM2048khz; } VOLATILE(sys2_IPINT.ipintcntl1,u32) = SYS2_IP_SLOT_MASK ; }/* p_dr18_IOMInit */# if(DAFEATURES & DAF_FSIHOOK_ARM)void p_arm_customer_fsi_io(s32 *arm_dfl_sb){ s32 s32_Am1 = 0; s32 s32_Data0 = 0x0000; s32_Am1 = arm_dfl_sb[DSP_SB_AME1_OUTPUT]; // AME1 output VOLATILE(sys2_IPINT.hpout0,u16) = s32_Am1<<8; //delayUs(60); s32_Data0 = VOLATILE(sys2_IPINT.hpin0,u16); arm_dfl_sb[DSP_SB_AMD1_INPUT] = s32_Data0>>8; // AMD1 input }# endif#else /* (NR_IOM_LINES>0) */# if(DAFEATURES & DAF_FSIHOOK_ARM)void p_arm_customer_fsi_io(s32 *arm_dfl_sb){}# endif#endif /* (NR_IOM_LINES>0) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -