##// END OF EJS Templates
Factorised stream device structure to reduce memory usage....
Factorised stream device structure to reduce memory usage. Improved Graphical terminal for multi instances.

File last commit:

r51:1ef095ac0ee3 dev_alexis
r51:1ef095ac0ee3 dev_alexis
Show More
main.c
73 lines | 1.9 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>
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
int main()
{
delay_100us(20000);
INA226_t ina5VSens,ina33VSens,ina15VSens;
gpioset(PSU_DISABLE);//enable psu!
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",current15V/1000);
printf("%dmA\n",current33V/1000);
printf("%dmA\n",current5V/1000);
}
printf("Exit\n\r");
return 0;
}