main.c
68 lines
| 2.0 KiB
| text/x-c
|
CLexer
|
r22 | #include <stdio.h> | ||
#include <fat32.h> | ||||
#include <gpio.h> | ||||
#include <uart.h> | ||||
#include <stm32f4xx.h> | ||||
#include <bsp.h> | ||||
#include <i2c.h> | ||||
|
r27 | #include <CS43L22.h> | ||
|
r29 | #include <ina226.h> | ||
|
r22 | |||
extern streamdevice* __opnfiles__[]; | ||||
int main() | ||||
{ | ||||
|
r30 | INA226_t ina5VSens,ina33VSens,ina15VSens; | ||
|
r29 | gpioset(PSU_DISABLE); | ||
|
r31 | volatile int16_t* regtest=(volatile int16_t*)0x60000000; | ||
volatile int16_t* regtest2=(volatile int16_t*)(0x60000000+(1<<20)); | ||||
|
r30 | //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); | ||||
|
r32 | *regtest=(int16_t)0; | ||
|
r31 | printf("LCD ID=%x\n\r",0xFFFF&(*regtest2)); | ||
|
r32 | *regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE; | ||
printf("ILI9328_REGISTER_ENTRYMODE=%x\n\r",0xFFFF&(*regtest2)); | ||||
*regtest=(int16_t)0x20; | ||||
*regtest2=(int16_t)0x0; | ||||
*regtest=(int16_t)0x21; | ||||
*regtest2=(int16_t)0x0; | ||||
*regtest=(int16_t)0x22; | ||||
for(volatile int i=0;i<1024*64;i++) | ||||
{ | ||||
*regtest2=(int16_t)i; | ||||
} | ||||
|
r30 | 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"); | ||||
|
r22 | while(1) | ||
{ | ||||
|
r30 | for(volatile int i=0;i<1024*1024;i++); | ||
|
r22 | gpioset(LED1); | ||
gpioclr(LED2); | ||||
|
r30 | for(volatile int i=0;i<1024*1024;i++); | ||
|
r22 | gpioclr(LED1); | ||
gpioset(LED2); | ||||
|
r30 | //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); | ||||
|
r22 | } | ||
printf("hello world\n\r"); | ||||
return 0; | ||||
} | ||||