MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / efm32_spiLcd_writeRegister

Function efm32_spiLcd_writeRegister

bsp/efm32/dev_lcd.c:420–444  ·  view source on GitHub ↗

/ * @brief * Write data to SSD2119 controller * * @param[in] reg * Register to write to * * @param[in] data * 16-bit data to write into register * * @note * It's not possible to read back register value through SSD2119 SPI interface ******************************************************************************/

Source from the content-addressed store, hash-verified

418 * It's not possible to read back register value through SSD2119 SPI interface
419 ******************************************************************************/
420rt_err_t efm32_spiLcd_writeRegister(rt_uint8_t reg, rt_uint16_t data)
421{
422 struct efm32_usart_device_t *usart;
423 rt_uint8_t buf_ins[3];
424 rt_uint8_t buf_res[3];
425
426 RT_ASSERT(lcd != RT_NULL);
427 usart = (struct efm32_usart_device_t *)(lcd->user_data);
428
429 /* Build instruction buffer */
430 buf_res[0] = (data & 0xff00) >> 8;
431 buf_res[1] = data & 0x00ff;
432 buf_ins[0] = 1; /* Instruction length */
433 buf_ins[1] = reg; /* Instruction */
434 *(rt_uint8_t **)(&buf_ins[2]) = buf_res; /* Data */
435 efm32_spiLcd_cs(1);
436 if (lcd->write(lcd, EFM32_NO_DATA, buf_ins, 2) == 0)
437 {
438 lcd_debug("LCD: Write data failed!\n");
439 return -RT_ERROR;
440 }
441 efm32_spiLcd_cs(0);
442
443 return RT_EOK;
444}
445
446/***************************************************************************//**
447 * @brief

Callers

nothing calls this directly

Calls 2

efm32_spiLcd_csFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected