mirror of
https://github.com/DualTachyon/uv-k5-firmware.git
synced 2024-11-21 05:30:49 +08:00
Fixed delay function names to their actual units.
This commit is contained in:
parent
67e7a85b05
commit
7e2a824bca
@ -50,6 +50,6 @@ void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer)
|
||||
|
||||
I2C_Stop();
|
||||
|
||||
SYSTEM_DelayUs(10);
|
||||
SYSTEM_DelayMs(10);
|
||||
}
|
||||
|
||||
|
50
driver/i2c.c
50
driver/i2c.c
@ -23,25 +23,25 @@
|
||||
void I2C_Start(void)
|
||||
{
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
}
|
||||
|
||||
void I2C_Stop(void)
|
||||
{
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
}
|
||||
|
||||
uint8_t I2C_Read(bool bFinal)
|
||||
@ -55,33 +55,33 @@ uint8_t I2C_Read(bool bFinal)
|
||||
Data = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
Data <<= 1;
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
if (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA)) {
|
||||
Data |= 1U;
|
||||
}
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
}
|
||||
|
||||
PORTCON_PORTA_IE &= ~PORTCON_PORTA_IE_A11_MASK;
|
||||
PORTCON_PORTA_OD |= PORTCON_PORTA_OD_A11_BITS_ENABLE;
|
||||
GPIOA->DIR |= GPIO_DIR_11_BITS_OUTPUT;
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
if (bFinal) {
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
} else {
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
}
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
return Data;
|
||||
}
|
||||
@ -92,7 +92,7 @@ int I2C_Write(uint8_t Data)
|
||||
int ret = -1;
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
for (i = 0; i < 8; i++) {
|
||||
if ((Data & 0x80) == 0) {
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
@ -100,20 +100,20 @@ int I2C_Write(uint8_t Data)
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
}
|
||||
Data <<= 1;
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
}
|
||||
|
||||
PORTCON_PORTA_IE |= PORTCON_PORTA_IE_A11_BITS_ENABLE;
|
||||
PORTCON_PORTA_OD &= ~PORTCON_PORTA_OD_A11_MASK;
|
||||
GPIOA->DIR &= ~GPIO_DIR_11_MASK;
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
for (i = 0; i < 255; i++) {
|
||||
if (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA) == 0) {
|
||||
@ -123,7 +123,7 @@ int I2C_Write(uint8_t Data)
|
||||
}
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
PORTCON_PORTA_IE &= ~PORTCON_PORTA_IE_A11_MASK;
|
||||
PORTCON_PORTA_OD |= PORTCON_PORTA_OD_A11_BITS_ENABLE;
|
||||
GPIOA->DIR |= GPIO_DIR_11_BITS_OUTPUT;
|
||||
@ -143,11 +143,11 @@ int I2C_ReadBuffer(void *pBuffer, uint8_t Size)
|
||||
}
|
||||
|
||||
for (i = 0; i < Size - 1; i++) {
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
pData[i] = I2C_Read(false);
|
||||
}
|
||||
|
||||
SYSTICK_Delay(1);
|
||||
SYSTICK_DelayUs(1);
|
||||
pData[i++] = I2C_Read(true);
|
||||
|
||||
return Size;
|
||||
|
@ -70,7 +70,7 @@ void ST7565_BlitFullScreen(void)
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
}
|
||||
|
||||
SYSTEM_DelayUs(20);
|
||||
SYSTEM_DelayMs(20);
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ void ST7565_Init(void)
|
||||
ST7565_Configure_GPIO_B11();
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
ST7565_WriteByte(0xE2);
|
||||
SYSTEM_DelayUs(0x78);
|
||||
SYSTEM_DelayMs(0x78);
|
||||
ST7565_WriteByte(0xA2);
|
||||
ST7565_WriteByte(0xC0);
|
||||
ST7565_WriteByte(0xA1);
|
||||
@ -126,14 +126,14 @@ void ST7565_Init(void)
|
||||
ST7565_WriteByte(0x81);
|
||||
ST7565_WriteByte(0x1F);
|
||||
ST7565_WriteByte(0x2B);
|
||||
SYSTEM_DelayUs(1);
|
||||
SYSTEM_DelayMs(1);
|
||||
ST7565_WriteByte(0x2E);
|
||||
SYSTEM_DelayUs(1);
|
||||
SYSTEM_DelayMs(1);
|
||||
ST7565_WriteByte(0x2F);
|
||||
ST7565_WriteByte(0x2F);
|
||||
ST7565_WriteByte(0x2F);
|
||||
ST7565_WriteByte(0x2F);
|
||||
SYSTEM_DelayUs(0x28);
|
||||
SYSTEM_DelayMs(0x28);
|
||||
ST7565_WriteByte(0x40);
|
||||
ST7565_WriteByte(0xAF);
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
@ -144,11 +144,11 @@ void ST7565_Init(void)
|
||||
void ST7565_Configure_GPIO_B11(void)
|
||||
{
|
||||
GPIO_SetBit(&GPIOB->DATA, 11);
|
||||
SYSTEM_DelayUs(1);
|
||||
SYSTEM_DelayMs(1);
|
||||
GPIO_ClearBit(&GPIOB->DATA, 11);
|
||||
SYSTEM_DelayUs(20);
|
||||
SYSTEM_DelayMs(20);
|
||||
GPIO_SetBit(&GPIOB->DATA, 11);
|
||||
SYSTEM_DelayUs(120);
|
||||
SYSTEM_DelayMs(120);
|
||||
}
|
||||
|
||||
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line)
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include "driver/system.h"
|
||||
#include "driver/systick.h"
|
||||
|
||||
void SYSTEM_DelayUs(uint32_t Delay)
|
||||
void SYSTEM_DelayMs(uint32_t Delay)
|
||||
{
|
||||
SYSTICK_Delay(Delay * 1000);
|
||||
SYSTICK_DelayUs(Delay * 1000);
|
||||
}
|
||||
|
||||
void SYSTEM_ConfigureClocks(void)
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void SYSTEM_DelayUs(uint32_t Delay);
|
||||
void SYSTEM_DelayMs(uint32_t Delay);
|
||||
void SYSTEM_ConfigureClocks(void);
|
||||
|
||||
#endif
|
||||
|
@ -26,7 +26,7 @@ void SYSTICK_Init(void)
|
||||
gTickMultiplier = 48;
|
||||
}
|
||||
|
||||
void SYSTICK_Delay(uint32_t Delay)
|
||||
void SYSTICK_DelayUs(uint32_t Delay)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t Start;
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
void SYSTICK_Init(void);
|
||||
void SYSTICK_Delay(uint32_t Delay);
|
||||
void SYSTICK_DelayUs(uint32_t Delay);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user