diff --git a/nokia.c b/nokia.c index e07e0d3..88e82d0 100644 --- a/nokia.c +++ b/nokia.c @@ -43,67 +43,34 @@ const size_t gNokiaBufferSize = sizeof(gNokiaBuffer); /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void NokiaControl(uint8_t controlByte) { - // TODO: write code here + // Activate Control on SPI device (DC = 0) HAL_GPIO_WritePin(D_C_NOKIA_GPIO_Port, D_C_NOKIA_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(CS_NOKIA_GPIO_Port, CS_NOKIA_Pin, GPIO_PIN_RESET); - - // HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout) - /* - HAL_OK = 0x00U, - HAL_ERROR = 0x01U, - HAL_BUSY = 0x02U, - HAL_TIMEOUT = 0x03U - HAL_StatusTypeDef - */ - - /*HAL_DMA_State - HAL_DMA_STATE_RESET = 0x00U, !< DMA not yet initialized or disabled - HAL_DMA_STATE_READY = 0x01U, !< DMA initialized and ready for use - HAL_DMA_STATE_BUSY = 0x02U, !< DMA process is ongoing - HAL_DMA_STATE_TIMEOUT = 0x03U, !< DMA timeout state - HAL_DMA_STATE_ERROR = 0x04U, !< DMA error state - HAL_DMA_STATE_ABORT = 0x05U, !< DMA Abort state -}HAL_DMA_StateTypeDef; -*/ + // Select the Nokia LCD (CS = 0) + HAL_GPIO_WritePin(CS_NOKIA_GPIO_Port, CS_NOKIA_Pin, GPIO_PIN_RESET); + + // Send the control byte HAL_SPI_Transmit(&hspi2, &controlByte, 1, 10); - /* - if(HAL_SPI_Transmit(&hspi2, &controlByte, 1, 10)!=HAL_OK){ - //#PROBLEM !!! - printf("Error while sending Control Data\r\n"); - }*/ + + // Deselect the Nokia LCD (CS = 1) HAL_GPIO_WritePin(CS_NOKIA_GPIO_Port, CS_NOKIA_Pin, GPIO_PIN_SET); + + // Activate Data on SPI device (DC = 1) HAL_GPIO_WritePin(D_C_NOKIA_GPIO_Port, D_C_NOKIA_Pin, GPIO_PIN_SET); - - - // Code Done - - + } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void NokiaData(uint8_t dataByte) { - // TODO: write code here + // Select the Nokia LCD (CS = 0) HAL_GPIO_WritePin(CS_NOKIA_GPIO_Port, CS_NOKIA_Pin, GPIO_PIN_RESET); - - // HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout) - /* - HAL_OK = 0x00U, - HAL_ERROR = 0x01U, - HAL_BUSY = 0x02U, - HAL_TIMEOUT = 0x03U - */ - - + // Send the data byte HAL_SPI_Transmit(&hspi2, &dataByte, 1, 10); - /* - if(HAL_SPI_Transmit(&hspi2, &dataByte, 1, 0)!=HAL_OK){ - //#PROBLEM !!! - printf("Error while sending Control Data\r\n"); - } */ + + // Deselect the Nokia LCD (CS = 1) HAL_GPIO_WritePin(CS_NOKIA_GPIO_Port, CS_NOKIA_Pin, GPIO_PIN_SET); }