Polish nokia.c

This commit is contained in:
Rémi Heredero 2023-12-14 21:29:30 +01:00
parent e0c5169224
commit c5e5a2f6ea

57
nokia.c
View File

@ -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);
}