|
|
#include <stdio.h>
|
|
|
#include <fat32.h>
|
|
|
#include <gpio.h>
|
|
|
#include <uart.h>
|
|
|
#include <stm32f4xx.h>
|
|
|
#include <bsp.h>
|
|
|
#include <i2c.h>
|
|
|
#include <CS43L22.h>
|
|
|
#include <ina226.h>
|
|
|
#include <fonts.h>
|
|
|
|
|
|
|
|
|
extern streamdevice* __opnfiles__[];
|
|
|
|
|
|
int main()
|
|
|
{
|
|
|
INA226_t ina5VSens,ina33VSens,ina15VSens;
|
|
|
gpioset(PSU_DISABLE);
|
|
|
volatile int16_t* regtest=(volatile int16_t*)0x60000000;
|
|
|
volatile int16_t* regtest2=(volatile int16_t*)(0x61FFFFF0);
|
|
|
//ina226open(&ina5VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,0,15,1000000);
|
|
|
//ina226open(&ina15VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,1,0,15,1000000);
|
|
|
*regtest=(int16_t)0;
|
|
|
printf("LCD ID=%x\n\r",0xFFFF&(*regtest2));
|
|
|
|
|
|
while(1)
|
|
|
{
|
|
|
/* *regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE;
|
|
|
*regtest2=(int16_t)0x1008;*/
|
|
|
ili9328setFrame(&lcd0,0,0,240,320);
|
|
|
*regtest=(int16_t)0x22;
|
|
|
for(volatile int i=0;i<(320*240);i++)
|
|
|
{
|
|
|
*regtest2=(int16_t)0x001F;
|
|
|
//for(volatile int l=0;l<(1024);l++);
|
|
|
|
|
|
}
|
|
|
/* *regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE;
|
|
|
*regtest2=(int16_t)0x1018;*/
|
|
|
for(volatile int i=0;i<(320*240*100);i++);
|
|
|
/* *regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE;
|
|
|
*regtest2=(int16_t)0x1008;*/
|
|
|
//ili9328setGRAMaddress(&lcd0,60,80);
|
|
|
uint16_t test[80*80];
|
|
|
ili9328setFrame(&lcd0,10,10,100,100);
|
|
|
*regtest=(int16_t)0x22;
|
|
|
for(volatile int i=0;i<(100*100);i++)
|
|
|
{
|
|
|
*regtest2=(int16_t)(0xF800);
|
|
|
//test[i]=(int16_t)0xF800;
|
|
|
//for(volatile int l=0;l<(1024);l++);
|
|
|
|
|
|
}
|
|
|
//lcd0.paint(&lcd0,test,100,100,80,80);
|
|
|
/**regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE;
|
|
|
*regtest2=(int16_t)0x1018;*/
|
|
|
for(volatile int i=0;i<(320*240*100);i++);
|
|
|
}
|
|
|
|
|
|
if(-1==ina226open(&ina33VSens,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 3.3V monitor\n\r");
|
|
|
}
|
|
|
|
|
|
int current5V,current33V,current15V;
|
|
|
printf("\t5V\t3.3V\n\r");
|
|
|
while(1)
|
|
|
{
|
|
|
for(volatile int i=0;i<1024*1024;i++);
|
|
|
gpioset(LED1);
|
|
|
gpioclr(LED2);
|
|
|
for(volatile int i=0;i<1024*1024;i++);
|
|
|
gpioclr(LED1);
|
|
|
gpioset(LED2);
|
|
|
//current5V = ina226getCurrent(&ina5VSens);
|
|
|
current33V = ina226getCurrent(&ina33VSens);
|
|
|
//current15V = ina226getCurrent(&ina15VSens);
|
|
|
//current = ina226getReg(&Psens1,INA226_Current_Reg);
|
|
|
//printf("%duA %dmA\t%duA %dmA\n\r",current5V,current5V/1000,current33V,current33V/1000);
|
|
|
printf("%duA %dmA\n\r",current33V,current33V/1000);
|
|
|
}
|
|
|
printf("hello world\n\r");
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|