##// END OF EJS Templates
Corrected bug 591
Corrected bug 591

File last commit:

r56:bf21d93f0037 dev_alexis
r56:bf21d93f0037 dev_alexis
Show More
main.c
83 lines | 2.3 KiB | text/x-c | CLexer
#include <stdio.h>
#include <fat32.h>
#include <gpio.h>
#include <uart.h>
#include <stm32f4xx.h>
#include <math.h>
#include <bsp.h>
#include <i2c.h>
#include <CS43L22.h>
#include <ina226.h>
#include <fonts.h>
#include <stdlib.h>
#include <core.h>
#include <malloc.h>
extern streamdevice* __opnfiles__[];
#define LCD_COLOR_WHITE 0xFFFF
#define LCD_COLOR_BLACK 0x0000
#define LCD_COLOR_GREY 0xF7DE
#define LCD_COLOR_BLUE 0x001F
#define LCD_COLOR_BLUE2 0x051F
#define LCD_COLOR_RED 0xF800
#define LCD_COLOR_MAGENTA 0xF81F
#define LCD_COLOR_GREEN 0x07E0
#define LCD_COLOR_CYAN 0x7FFF
#define LCD_COLOR_YELLOW 0xFFE0
#ifndef PSU_DISABLE
#define PSU_DISABLE LED1
#endif
void setUartAsStdout()
{
streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
uartmkstreamdev(uart,fd1);
__opnfiles__[1] = fd1;
}
int main()
{
delay_100us(20000);
INA226_t ina5VSens,ina33VSens,ina15VSens;
gpioset(PSU_DISABLE);//enable psu!
setUartAsStdout();
//ili9328paintFilRect(&lcd0,0,0,240,320,LCD_COLOR_BLACK,1,LCD_COLOR_BLACK);
if(-1==ina226open(&ina33VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,0,15,1000000))
{
printf("Can't open 3.3V monitor\n\r");
}
if(-1==ina226open(&ina5VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,1,15,1000000))
{
printf("Can't open 5V monitor\n\r");
}
if(-1==ina226open(&ina15VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,1,0,15,1000000))
{
printf("Can't open 1.5V monitor\n\r");
}
int current5V,current33V,current15V;
while(1)
{
current5V = ina226getCurrent(&ina5VSens);
current33V = ina226getCurrent(&ina33VSens);
current15V = ina226getCurrent(&ina15VSens);
printf("%dmA\n\r",current15V/1000);
printf("%dmA\n\r",current33V/1000);
printf("%dmA\n\r",current5V/1000);
delay_100us(10000);
}
printf("Exit\n\r");
return 0;
}