/* ****************************************************************************** * @file driver_ST7735S.c * @author �Ϻ����� * @version V1.0.0 * @date 2023 * @brief ST7735S driver. * This file provides firmware functions to manage gc9c01 * with SPI and DMA. User should set GPIO, dma channel, spi * channel according actual resource allocation. ****************************************************************************** * @attention * * Copyright (c) 2023 Bixdo. * All rights reserved. ****************************************************************************** */ #include "ALLinclude.h" #include "FuctionRGB.h" void F_RGB_IO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* Enable the GPIO_LED Clock */ __HAL_RCC_GPIOB_CLK_ENABLE(); /* Configure the GPIO_CE pin */ GPIO_InitStruct.Pin = Pin_LEDDout; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;//GPIO_MODE_OUTPUT_OD; GPIO_MODE_OUTPUT_PP GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(Port_LEDDout, &GPIO_InitStruct); } void F_UV_IO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* Enable the GPIO_LED Clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); HAL_GPIO_WritePin(Port_UV_ON,Pin_UV_ON,GPIO_PIN_RESET); HAL_GPIO_WritePin(Port_UV_CE,Pin_UV_CE,GPIO_PIN_RESET); /* Configure the GPIO_CE pin */ GPIO_InitStruct.Pin = Pin_UV_ON; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;//GPIO_MODE_OUTPUT_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(Port_UV_ON, &GPIO_InitStruct); /* Configure the GPIO_CE pin */ GPIO_InitStruct.Pin = Pin_UV_CE; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;//GPIO_MODE_OUTPUT_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(Port_UV_CE, &GPIO_InitStruct); HAL_GPIO_WritePin(Port_UV_ON,Pin_UV_ON,GPIO_PIN_RESET); HAL_GPIO_WritePin(Port_UV_CE,Pin_UV_CE,GPIO_PIN_RESET); } void Function_UV_ON(void) { HAL_GPIO_WritePin(Port_UV_ON,Pin_UV_ON,GPIO_PIN_SET); HAL_GPIO_WritePin(Port_UV_CE,Pin_UV_CE,GPIO_PIN_SET); } void Function_UV_OFF(void) { HAL_GPIO_WritePin(Port_UV_ON,Pin_UV_ON,GPIO_PIN_RESET); HAL_GPIO_WritePin(Port_UV_CE,Pin_UV_CE,GPIO_PIN_RESET); } static void delayMicroseconds(uint8_t delaydata) { uint8_t delay = delaydata; while(delay){ delay--; }; } // 发送一个bit的函数 static void sendBit(uint32_t bitValue) { if(bitValue ) { setOutput_H; delayMicroseconds(BIT1_HIGH); setOutput_L; // delayMicroseconds(BIT1_LOW); } else { setOutput_H; delayMicroseconds(BIT0_HIGH); setOutput_L; delayMicroseconds(BIT0_LOW); } } // 发送一个字节的函数 static void sendByte(uint8_t data) { uint8_t datasend[8]; for(int i=0; i<8; i++) { // datasend[i] = (data & (1<