Example #1
0
/*!
 * \brief Writes a byte and reads the value
 * \param val Value to write. This value will be shifted out
 * \return The value shifted in
 */
static uint8_t SPI_WriteRead(uint8_t val) {
    uint8_t ch;

    while (SM1_GetCharsInTxBuf()!=0) {} /* wait until tx is empty */
    while (SM1_SendChar(val)!=ERR_OK) {} /* send character */
    while (SM1_GetCharsInTxBuf()!=0) {} /* wait until data has been sent */
    while (SM1_GetCharsInRxBuf()==0) {} /* wait until we receive data */
    while (SM1_RecvChar(&ch)!=ERR_OK) {} /* get data */
    return ch;
}
Example #2
0
uint8_t HardwareSPI::transfer(uint8_t val) {
  uint8_t ch;

  while(SM1_GetCharsInTxBuf()!=0) {} /* wait until tx is empty */
  while(SM1_SendChar(val)!=ERR_OK) {} /* send character */
  while(SM1_GetCharsInTxBuf()!=0) {} /* wait until data has been sent */
  while(SM1_GetCharsInRxBuf()==0) {} /* wait until we receive data */
  while(SM1_RecvChar(&ch)!=ERR_OK) {} /* get data */
  return ch;
}
Example #3
0
uint8_t mcp3301Read(void){
  uint8_t i;
   
      MCP3301_ENABLE;
      MCP3301_RecvCh(&i);     // read ch
      for(i=0;i<2;i++){
//          MCP3301_SendCh(0x55);
 while(ERR_TXFULL == SM1_SendChar(0x55)); 
                      while( !SPI1S_SPTEF ) ;
          MCP3301_RecvCh(&mcpADC1[i]);  
//             WDog_Clear();
      }
      MCP3301_DISABLE; 
   
   return ;
}