void uart_tx(uint8_t* txBuf, uint8_t txBufLen) { // register data to send uart_vars.txBuf = txBuf; uart_vars.txBufLen = txBufLen; // enable UART TX interrupt SCI2C2_TIE = 0x1; // send first byte sci2_PutChar(*uart_vars.txBuf); }
void interrupt VectorNumber_Vsci2tx SCI2TX_int(void) { // one byte less to go uart_vars.txBufLen--; uart_vars.txBuf++; if (uart_vars.txBufLen>0) { // send next byte sci2_PutChar(*uart_vars.txBuf); } else { if (uart_vars.txDone_cb!=NULL) { // disable UART1 TX interrupt SCI2C2_TIE = 0x0; // call the callback uart_vars.txDone_cb(); }//poipoi } }
/*FUNCTION*---------------------------------------------------------------- * * Function Name : CDC_Task * Returned Value : none * Comments : * Execution starts here * *END*--------------------------------------------------------------------*/ void CDC_Task () { /* Body */ USB_STATUS status = USB_OK; uint_32 i = 0; static uint_32 char_to_recv = 0; /* due to the fact that uart driver blocks task, we will check if char is available and then we read it */ /* write them to USB */ if(USB_EVENT_NOT_SET == _usb_event_wait_ticks(&device_registered, 0x01, TRUE, 0)) return; if (0 == check_open) { _io_cdc_serial_open(f_usb, device_name, (char *)&usb_open_param); check_open = 1; } else { #ifdef MCU_mcf51jf128 /* todo AI: change this for MCU_mcf51jf128 */ char temp; temp = TERMIO_GetChar(); if(temp) { buff_index = 1; buff[0] = temp; } #endif /* MCU_mcf51jf128 */ /* Read data from UART */ #if 0 /* << EST */ DisableInterrupts; uart2usb_num = buff_index; for (i = 0; i < buff_index; i++) { uart2usb[i] = buff[i]; } buff_index = 0; EnableInterrupts; #endif #if 0 /* << EST */ /* Write data to USB */ if (uart2usb_num) { num_done = _io_cdc_serial_write(f_usb, uart2usb, (int_32)(sizeof(uart2usb[0]) * uart2usb_num)); if(num_done > 0) { for (i = (uint_32)num_done; i < uart2usb_num; i++) /* move buffer data, remove the written ones */ uart2usb[i - num_done] = uart2usb[i]; uart2usb_num -= num_done; char_to_recv += num_done; } } #endif /* Read data from USB */ if(char_to_recv > 0) { num_done = _io_cdc_serial_read(f_usb, usb2uart + usb2uart_num, (int_32)(sizeof(uart2usb) / sizeof(uart2usb[0]) - usb2uart_num)); if(num_done > 0) { usb2uart_num += num_done; if(char_to_recv >= num_done) { char_to_recv -= num_done; } else { char_to_recv = 0; } } else { char_to_recv = 0; } } /* write them to UART */ if (usb2uart_num > 0) { #if 0 /* << EST */ for (i = 0; i < usb2uart_num; i++) { #ifdef MCU_mcf51jf128 printf(" --received--> %%c\n\r",usb2uart[i]); #else sci2_PutChar(usb2uart[i]); #endif } #endif usb2uart_num = 0; } } } /* Endbody */