main.c
86 lines
| 2.7 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> | ||
|
r35 | #include <fonts.h> | ||
|
r22 | |||
extern streamdevice* __opnfiles__[]; | ||||
|
r37 | #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 | ||||
|
r22 | int main() | ||
{ | ||||
|
r30 | INA226_t ina5VSens,ina33VSens,ina15VSens; | ||
|
r29 | gpioset(PSU_DISABLE); | ||
|
r31 | volatile int16_t* regtest=(volatile int16_t*)0x60000000; | ||
|
r34 | volatile int16_t* regtest2=(volatile int16_t*)(0x61FFFFF0); | ||
|
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)); | ||
|
r37 | uint16_t x=90,y=0; | ||
ili9328paintFilRect(&lcd0,0,0,240,320,0x01F,0x01F); | ||||
// ili9328paintText(&lcd0,"Hello",14,38,&Font16x24,0); | ||||
ili9328paintText(&lcd0,"Hello",10,34,&Font16x24,0xF800); | ||||
|
r35 | while(1) | ||
|
r32 | { | ||
|
r37 | ili9328paintText(&lcd0," World !",90,y+24,&Font16x24,0xF800); | ||
ili9328paintFilRect(&lcd0,x,y,20,20,0x01F,0xF800); | ||||
for(volatile int i=0;i<(320*500);i++); | ||||
ili9328paintFilRect(&lcd0,90,y,150,24,0x01F,0x01F); | ||||
ili9328paintFilRect(&lcd0,x,y,20,20,0x01F,0x01F); | ||||
y+=10; | ||||
if(y>290){y=0;x+=20;} | ||||
if(x>220){x=90;} | ||||
|
r32 | } | ||
|
r33 | |||
|
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; | ||||
} | ||||