# HG changeset patch # User jeandet # Date 2013-06-14 15:38:57 # Node ID bf21d93f00376c43d49e6033fccf01a80f668195 # Parent c31e6b955f5b0ace5c9c6b1ac64b6c08eb0b9a5d Corrected bug #591 diff --git a/bsp/src/BEAGLESYNTH/bsp.c b/bsp/src/BEAGLESYNTH/bsp.c --- a/bsp/src/BEAGLESYNTH/bsp.c +++ b/bsp/src/BEAGLESYNTH/bsp.c @@ -208,7 +208,7 @@ void bsp_spi_init() void bsp_iic_init() { - i2copenandconfig(i2c2,0,400000,PF0,PF1); + i2copenandconfig(i2c2,0,10000,PF0,PF1); } void bsp_SD_init() @@ -306,3 +306,7 @@ void bsp_GTerm_init() + + + + diff --git a/bsp/src/BEAGLESYNTH/bsp.pri b/bsp/src/BEAGLESYNTH/bsp.pri --- a/bsp/src/BEAGLESYNTH/bsp.pri +++ b/bsp/src/BEAGLESYNTH/bsp.pri @@ -1,6 +1,9 @@ CPU=stm32f4xxxG DEFINES+=BSP=\\\"BEAGLESYNTH\\\" beagleCp.target = beagleCp -beagleCp.commands = scp $$DESTDIR/$(QMAKE_TARGET).bin root@192.168.7.2://opt/stm32flashAje/hello.bin -QMAKE_EXTRA_TARGETS += beagleCp +beagleCp.commands = cd bin && scp $(QMAKE_TARGET).bin root@192.168.7.2://opt/stm32flashAje/hello.bin +beagleCp131.target = beagleCp131 +beagleCp131.commands = cd bin && scp $(QMAKE_TARGET).bin root@129.104.27.131://opt/stm32flashAje/hello.bin +QMAKE_EXTRA_TARGETS += beagleCp beagleCp131 + UCMODEL=stm32f4 diff --git a/bsp/src/STM32F4Eval/bsp.c b/bsp/src/STM32F4Eval/bsp.c --- a/bsp/src/STM32F4Eval/bsp.c +++ b/bsp/src/STM32F4Eval/bsp.c @@ -247,7 +247,7 @@ void bsp_spi_init() void bsp_iic_init() { - //i2copenandconfig(i2c2,0,400000,PF0,PF1); + i2copenandconfig(i2c1,0,100000,PB9,PB6); } void bsp_SD_init() diff --git a/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro b/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro --- a/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro +++ b/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro @@ -3,12 +3,21 @@ CONFIG += cpu UCMODEL=stm32f4 -DEFINES += CPUFREQ=160000000 +DEFINES += CPUFREQ=40000000 -#BSP = BEAGLESYNTH +BSP = BEAGLESYNTH #BSP = SOLAR_LFR_PSU -BSP = STM32F4Eval +#BSP = STM32F4Eval SOURCES += \ main.c + + + + +#beagleCp.target = beagleCp +#beagleCp.commands = cd bin && scp $(QMAKE_TARGET).bin root@192.168.7.2://opt/stm32flashAje/hello.bin +#beagleCp131.target = beagleCp131 +#beagleCp131.commands = cd bin && scp $(QMAKE_TARGET).bin root@129.104.27.131://opt/stm32flashAje/hello.bin +#QMAKE_EXTRA_TARGETS += beagleCp beagleCp131 diff --git a/examples/BeagleSynthHelloSupMon/main.c b/examples/BeagleSynthHelloSupMon/main.c --- a/examples/BeagleSynthHelloSupMon/main.c +++ b/examples/BeagleSynthHelloSupMon/main.c @@ -11,6 +11,7 @@ #include #include #include +#include extern streamdevice* __opnfiles__[]; @@ -30,13 +31,21 @@ extern streamdevice* __opnfiles__[]; #define PSU_DISABLE LED1 #endif +void setUartAsStdout() +{ + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); + uartmkstreamdev(uart,fd1); + __opnfiles__[1] = fd1; +} 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); + setUartAsStdout(); + //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"); @@ -55,9 +64,10 @@ int main() 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("%dmA\n\r",current15V/1000); + printf("%dmA\n\r",current33V/1000); + printf("%dmA\n\r",current5V/1000); + delay_100us(10000); } printf("Exit\n\r"); return 0; diff --git a/examples/lcdTerminal/lcdTerminal.pro b/examples/lcdTerminal/lcdTerminal.pro --- a/examples/lcdTerminal/lcdTerminal.pro +++ b/examples/lcdTerminal/lcdTerminal.pro @@ -6,7 +6,7 @@ UCMODEL=stm32f4 BSP = STM32F4Eval -DEFINES += CPUFREQ=160000000 +DEFINES += CPUFREQ=40000000 SOURCES += \ main.c diff --git a/examples/lcdTerminal/main.c b/examples/lcdTerminal/main.c --- a/examples/lcdTerminal/main.c +++ b/examples/lcdTerminal/main.c @@ -26,9 +26,17 @@ extern streamdevice* __opnfiles__[__MAX_ #define LCD_COLOR_CYAN 0x7FFF #define LCD_COLOR_YELLOW 0xFFE0 +void testAudioDAC() +{ + CS43L22_t dac; + cs43l22open(&dac,i2c1,0); + uint8_t ID= cs43l22getID(&dac); + printf("dac ID = %d\n\r",ID); +} int main() { + delay_100us(10000); uint16_t innerbuffer[16]; uint16_t outterbuffer[16]; for(int i=0;i<16;i++)innerbuffer[i]=LCD_COLOR_BLUE; @@ -48,6 +56,8 @@ int main() printf("Line cnt :\n \t%d\n",terminal0.lineCount); printf("Column cnt :\n \t%d\n",terminal0.columnCount); printf("CPU Freq :\n \t%dMHz\n",getCpuFreq()/1000000); + //testAudioDAC(); + i2cwrite(i2c1,0x4a," ",1); while(1) { i%=1000; diff --git a/lib/src/common/POWER/ina226/ina226.c b/lib/src/common/POWER/ina226/ina226.c --- a/lib/src/common/POWER/ina226/ina226.c +++ b/lib/src/common/POWER/ina226/ina226.c @@ -29,7 +29,7 @@ int ina226open(INA226_t *dev, i2c_t i2cd if(dev != NULL) { dev->i2cdev=i2cdev; - dev->devAddress = INA226_I2C_ADDRESS | (A0 & 1) | ((A1<<1) & 2); + dev->devAddress = INA226_I2C_ADDRESS | (A0 & 1) | ((A1<<2) & 5); printf("dev->devAddress = %x\n\r",dev->devAddress); dev->shuntmOhm = shuntmOhm; dev->CurrentRangeuAmp = CurrentRangeuAmp; diff --git a/lib/src/stm32f4/I2C/i2c.c b/lib/src/stm32f4/I2C/i2c.c --- a/lib/src/stm32f4/I2C/i2c.c +++ b/lib/src/stm32f4/I2C/i2c.c @@ -39,8 +39,7 @@ i2c_t i2copen(int count) #define _INIT_DEV(_RCC_) \ RCC_APB1PeriphClockCmd(_RCC_, ENABLE); \ RCC_APB1PeriphResetCmd(_RCC_, ENABLE); \ - RCC_APB1PeriphResetCmd(_RCC_, DISABLE); \ - RCC_APB1PeriphClockCmd(_RCC_, ENABLE); + RCC_APB1PeriphResetCmd(_RCC_, DISABLE); switch(count) { @@ -70,7 +69,7 @@ i2c_t i2copenandconfig(int count,uint32_ i2cclose(dev); i2csetpins(dev,SDA,SCL); i2copen(count); - i2cenable(count); + //i2cenable(count); //I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev]; i2csetspeed(dev,speed); i2cenable(count); @@ -99,7 +98,7 @@ int i2cclose(i2c_t dev) int i2csetpins(i2c_t dev, uint32_t SDA, uint32_t SCL) { - if((dev<3)&&(dev>=0)) + if((dev=i2c1)) { gpio_t SDApin,SCLpin; SDApin = gpioopen(SDA); @@ -144,7 +143,7 @@ int i2csetpins(i2c_t dev, uint32_t SDA, int i2cenable(i2c_t dev) { - if((dev<3)&&(dev>=0)) + if((dev=i2c1)) { I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev]; _dev_->CR1 |=1 ; @@ -155,7 +154,7 @@ int i2cenable(i2c_t dev) int i2cdisable(i2c_t dev) { - if((dev<3)&&(dev>=0)) + if((dev=i2c1)) { I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev]; _dev_->CR1 &= ~1; @@ -167,7 +166,7 @@ int i2cdisable(i2c_t dev) int i2csetspeed(i2c_t dev,uint32_t speed) { - if((dev<3)&&(dev>=0)) + if((dev=i2c1)) { I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev]; int32_t APB1Freq=getAPB1Freq()/1000000; @@ -193,9 +192,9 @@ int i2csetspeed(i2c_t dev,uint32_t speed } else { - tmpreg &= ~(1<<15); - tmpreg &= ~(0xfff); - tmpreg |= 0xfff & (APB1Freq/(2*speed)); + tmpreg &= ~(1<<15); + tmpreg &= ~(0xfff); + tmpreg |= 0xfff & (APB1Freq/(2*speed)); } _dev_->CCR=tmpreg; tmpreg=_dev_->TRISE; @@ -211,7 +210,7 @@ int i2csetspeed(i2c_t dev,uint32_t speed int i2cbusy(i2c_t dev) { - if((dev<3)&&(dev>=0)) + if((dev=i2c1)) { I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev]; if((_dev_->SR2 & 2) ==2) return 1; /* Dev is busy */ @@ -222,25 +221,37 @@ int i2cbusy(i2c_t dev) int i2cwrite(i2c_t dev,char address,char* data,int count) { - if((dev<3)&&(dev>=0)) + if((dev=i2c1)) { int timeout=i2ctimeout; I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev]; while(i2cbusy(dev)) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } _dev_->CR1 |= 1<<8; timeout=i2ctimeout; while(!i2cStatusCheck(dev,((uint32_t)0x00030001))) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } _dev_->DR= address<<1; timeout=i2ctimeout; while(!i2cStatusCheck(dev, ((uint32_t)0x00070082))) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } address=_dev_->SR2; for(int i=0;iDR= data[i]; } timeout=i2ctimeout; while(!i2cStatusCheck(dev,1<<7)) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } timeout=i2ctimeout; while(!i2cStatusCheck(dev,1<<2)) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } _dev_->CR1 |= 1<<9; return count; @@ -270,25 +293,37 @@ int i2cwrite(i2c_t dev,char address,char int i2cread(i2c_t dev,char address,char* data,int count) { - if((dev<3)&&(dev>=0)) + if((dev=i2c1)) { int i=0; int timeout=i2ctimeout; while(i2cbusy(dev)) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev]; _dev_->CR1 |= (1<<8) + (1<<10); timeout=i2ctimeout; while(!i2cStatusCheck(dev,0x00030001)) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } _dev_->DR= (address<<1) + 1; while(!i2cStatusCheck(dev,0x000002)) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } if(count==1) { @@ -300,7 +335,11 @@ int i2cread(i2c_t dev,char address,char* timeout=i2ctimeout; while(!i2cStatusCheck(dev,0x0000040)) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } data[i]=_dev_->DR; } @@ -309,13 +348,21 @@ int i2cread(i2c_t dev,char address,char* timeout=i2ctimeout; while(!i2cStatusCheck(dev,0x0000040)) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } data[i]=_dev_->DR; timeout=i2ctimeout; while(_dev_->CR1 & ((uint16_t)0x0200)) { - if(0==(timeout--))return -1; + if(0==(timeout--)) + { + printf("Exited on timeout @ line %d\n\r",__LINE__); + return -1; + } } _dev_->CR1 |= 1<<10; return count; @@ -327,7 +374,7 @@ int i2cread(i2c_t dev,char address,char* int i2cStatusCheck(i2c_t dev,int32_t flagMask) { int32_t flag; - if((dev<3)&&(dev>=0)) + if((dev=i2c1)) { I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev]; flag= _dev_->SR1 + (_dev_->SR2<<16);