##// END OF EJS Templates
sync
sync

File last commit:

r31:74dca42d580c default
r31:74dca42d580c default
Show More
main.c
57 lines | 1.7 KiB | text/x-c | CLexer
#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>
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*)(0x60000000+(1<<20));
//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=0;
printf("LCD ID=%x\n\r",0xFFFF&(*regtest2));
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;
}