Esempio n. 1
0
/***********************************************************************************************************************
* Function Name: R_GLYPH_DataSend
* Description  : Actually sends the byte out the RSPI. This also takes care of locking the RSPI peripheral.
* Arguments    : data - 
*                    The data to send.
* Return Value : none
***********************************************************************************************************************/
void glyph_send_byte(int8_t data)
{
  /* Attempt to lock the RSPI peripheral. */
  while (false == R_RSPI_Lock(GLYPH_RSPI_CHANNEL, GLYPH_RSPI_PID))
  {
    /* Wait until lock is given up. At this point another task must unlock the RSPI peripheral before we can 
       lock it here. This means this other task must unlock from an ISR or from another RTOS task. */
#if defined(RTOS_PRESENT)
    /* If an RTOS is defined then the current task can yield and come back later. Right now it is time based and 
       using FreeRTOS, but you could yield on a semaphore here as well. */ 
    vTaskDelay( GLYPH_LOCK_DELAY_MS / portTICK_RATE_MS );
#endif
  }
  
  /* The lock has been obtained. Now assert the LCD CS. */
  R_RSPI_Select(GLYPH_RSPI_CHANNEL, LCD_SELECTED, GLYPH_RSPI_PID);
  
  /* Send the data. */
  R_RSPI_Write(GLYPH_RSPI_CHANNEL, (const uint8_t *)&data, sizeof(data), GLYPH_RSPI_PID);
  
  /* Data is sent. Deselect the LCD. */    
  R_RSPI_Deselect(GLYPH_RSPI_CHANNEL, LCD_SELECTED, GLYPH_RSPI_PID);
  
  /* Release the lock. */
  R_RSPI_Unlock(GLYPH_RSPI_CHANNEL, GLYPH_RSPI_PID);
  
}/* End of function glyph_send_byte() */
Esempio n. 2
0
static uint8_t u8g_rx_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val)
{
	rspi_command_word_t command;
	command.cpha = RSPI_SPCMD_CPHA_SAMPLE_EVEN;
	command.cpol = RSPI_SPCMD_CPOL_IDLE_HI;
	command.bit_order = RSPI_SPCMD_ORDER_MSB_FIRST;
	command.bit_length = RSPI_SPCMD_BIT_LENGTH_8;
	command.br_div = RSPI_SPCMD_BR_DIV_1;
	R_RSPI_Write(handle,command,&val,sizeof(val));
	while(!g_rspi_callbackend);
	g_rspi_callbackend = 0;
//	ulTaskNotifyTake( pdTRUE, portMAX_DELAY );

  return  0;
}