/* This function writes out a word to the USIC FIFO transmit buffer register. * Returns true in case if the FIFO is not full else otherwise. * */ bool I2C001_WriteData \ (const I2C001Handle_type* I2CHandle,const I2C001_DataType* Data) { bool Result = (bool)FALSE; USIC_CH_TypeDef* I2CRegs = I2CHandle->I2CRegs; /* <<<DD_I2C001_API_5>>>*/ do { if(I2CRegs->PSR_IICMode & USIC_CH_PSR_IICMode_WTDF_Msk) { Result = (bool)FALSE; break; } if(USIC_IsTxFIFOfull(I2CRegs)) { Result = (bool)FALSE; } else { I2CRegs->IN[0] = \ (((uint32_t)Data->Data1.TDF_Type << 8) | Data->Data1.Data); Result = (bool)TRUE; } }while(0); return Result; }
/******************************************************************************* * @brief When fifo buffer is enabled, this function writes out a word * to the USIC FIFO transmit buffer register. Returns true if the FIFO is not * full else otherwise. * But when fifo buffer is disabled, this function writes a word to the USIC * standard transmit buffer register. Returns true in case if the TDV bit is not * set else otherwise. * * @param[in] Handle of type I2C003_HandleType * @param[out] Data Pointer to data of type I2C003_DataType * * @return bool <BR> * TRUE : if FIFO is not full or if TDV bit is not Set.<BR> * FALSE : if FIFO is full or if TDV bit is Set.<BR> * * <b>Reentrant: NO </b><BR> ******************************************************************************/ bool I2C003_WriteData(const I2C003_HandleType* Handle, \ const I2C003_DataType* Data) { bool Result = (bool)FALSE; USIC_CH_TypeDef* I2CRegs; I2CRegs = Handle->I2CRegs; if (!(USIC_CH_PSR_IICMode_WTDF_Msk & I2CRegs->PSR_IICMode)) { if(Handle->TxFifoEn) { if(!USIC_IsTxFIFOfull(I2CRegs)) { I2CRegs->IN[0] = \ (((uint32_t)Data->TDF_Type << 8) | Data->Payload); Result = (bool)TRUE; } }else if(!(USIC_CH_TCSR_TDV_Msk & I2CRegs->TCSR)) { I2CRegs->TBUF[0] = (((uint32_t)Data->TDF_Type << 8) | Data->Payload); Result = (bool)TRUE; } } return Result; }
uint32_t UART001_WriteDataMultiple( const UART001_HandleType* Handle, uint16_t* DataPtr, uint32_t Count) { uint32_t WriteCount = 0; USIC_CH_TypeDef* UartRegs = Handle->UartRegs; /* <<<DD_UART001_API_2>>>*/ while(Count) { while( USIC_IsTxFIFOfull(UartRegs) ); UartRegs->IN[0] = *DataPtr; Count--; WriteCount++; DataPtr++; } return WriteCount; }
uint32_t UART001_WriteDataMultiple ( const UART001_HandleType* Handle, uint16_t* DataPtr, uint32_t Count ) { uint32_t WriteCount = 0x00U; USIC_CH_TypeDef* UartRegs = Handle->UartRegs; DBG002_FUNCTION_ENTRY(APP_GID,UART001_FUN_ENTRY); /* <<<DD_UART001_API_2>>>*/ while(! USIC_IsTxFIFOfull(UartRegs)&& Count) { UartRegs->IN[0] = *DataPtr; Count--; WriteCount++; DataPtr++; } DBG002_FUNCTION_EXIT(APP_GID,UART001_FUN_EXIT); return WriteCount; }