|
@@ -51,16 +51,12 @@ void main(void)
|
|
BufferIndex = 0;
|
|
BufferIndex = 0;
|
|
int8_t i;
|
|
int8_t i;
|
|
uint32_t vbuf = 0;
|
|
uint32_t vbuf = 0;
|
|
- for (i=0; i<64; i++) {
|
|
|
|
|
|
+ for (i=0; i<ADC_SMPLS; i++) {
|
|
vbuf += ConversionBuffer[i];
|
|
vbuf += ConversionBuffer[i];
|
|
}
|
|
}
|
|
- vbuf *= ADC_VREF;
|
|
|
|
- vbuf += 512;
|
|
|
|
- vbuf /= 1023;
|
|
|
|
- vbuf *= 45727;
|
|
|
|
- vbuf += 5000;
|
|
|
|
- vbuf /= 10000;
|
|
|
|
- Voltage = vbuf;
|
|
|
|
|
|
+ vbuf *= VOLTAGE_MUL;
|
|
|
|
+ vbuf /= VOLT_MUL_MUL;
|
|
|
|
+ Voltage = vbuf / ADC_SMPLS;
|
|
}
|
|
}
|
|
showV();
|
|
showV();
|
|
showC();
|
|
showC();
|
|
@@ -80,10 +76,10 @@ static void showV(void) {
|
|
}
|
|
}
|
|
|
|
|
|
static void showC(void) {
|
|
static void showC(void) {
|
|
- LedDigits[4] = 5;
|
|
|
|
- LedDigits[5] = 6;
|
|
|
|
- LedDigits[6] = 7;
|
|
|
|
- LedDigits[7] = 8;
|
|
|
|
|
|
+ LedDigits[4] = VOLTAGE_MUL / 1000;
|
|
|
|
+ LedDigits[5] = (VOLTAGE_MUL % 1000) / 100;
|
|
|
|
+ LedDigits[6] = (VOLTAGE_MUL % 100) / 10;
|
|
|
|
+ LedDigits[7] = VOLTAGE_MUL % 10;
|
|
}
|
|
}
|
|
|
|
|
|
static void boardInit(void) {
|
|
static void boardInit(void) {
|
|
@@ -133,7 +129,7 @@ static void boardInit(void) {
|
|
GPIOD->CR2 |= (uint8_t)LED_SEG_AF;
|
|
GPIOD->CR2 |= (uint8_t)LED_SEG_AF;
|
|
|
|
|
|
/* `SPI` pins to Push-Pull, High, Fast */
|
|
/* `SPI` pins to Push-Pull, High, Fast */
|
|
- SPI_PORT->ODR = (uint8_t)(SPI_SCK|SPI_DATA);
|
|
|
|
|
|
+ SPI_PORT->ODR |= (uint8_t)(SPI_SCK|SPI_DATA);
|
|
SPI_PORT->DDR |= (uint8_t)(SPI_SCK|SPI_DATA);
|
|
SPI_PORT->DDR |= (uint8_t)(SPI_SCK|SPI_DATA);
|
|
SPI_PORT->CR1 |= (uint8_t)(SPI_SCK|SPI_DATA);
|
|
SPI_PORT->CR1 |= (uint8_t)(SPI_SCK|SPI_DATA);
|
|
SPI_PORT->CR2 |= (uint8_t)(SPI_SCK|SPI_DATA);
|
|
SPI_PORT->CR2 |= (uint8_t)(SPI_SCK|SPI_DATA);
|