# HG changeset patch # User jeandet # Date 2013-11-02 12:40:06 # Node ID 0f2d8fe5497f79ec6ec6ced72161a999893a34d6 # Parent 5e865c663d35ade157e67b6c305235be4032f92a UCMODEl is now a qmake parameter. diff --git a/README b/README --- a/README +++ b/README @@ -29,10 +29,17 @@ own licence. If you reconize any of your ____________ Intallation: ~~~~~~~~~~~~ - To install the libuc2 you just need to copy the libuc2 folder where you whant then you need to: - -set the libuc2 environement varriable, with linux you can append this to the end of your /etc/bashrc file: - libuc2=/opt/libuc2 - replace /opt/ by the path where is installed the libuc2. + -On linux you must copy the libuc2 folder to /opt/libuc2. Then you will be able to use /opt/libuc2/bin/qmake-libuc2 to generate Makefiles et build it. + +________________ +Building libuc2: +~~~~~~~~~~~~~~~~ + Usualy you work on one architecture at time, when you build the libuc2 you build it for one architecture at time but you can sequencially build it for + several architectures. First you have to generate Makefiles with qmake, call qmake in the libuc2 root folder with your target architecture as argument: + /opt/libuc2/bin/qmake-libuc2 UCMODEL=stm32f4 # Building for stm32f4 + make -j 4 # 4 if you have 4 core + + You can also work with QtCreator, just remember to set UCMODEL variable in your prject configuration. ______________ Contributions: diff --git a/bsp/src/BEAGLESYNTH/BEAGLESYNTH.pro b/bsp/src/BEAGLESYNTH/BEAGLESYNTH.pro deleted file mode 100644 --- a/bsp/src/BEAGLESYNTH/BEAGLESYNTH.pro +++ /dev/null @@ -1,22 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp - -CONFIG += bsp -CONFIG += gui power - -BSP = BEAGLESYNTH - -UCMODEL=stm32f4 - -SOURCES += bsp.c - -HEADERS += bsp.h - -LIBS+= -lgpio -luart -li2c -lspi - - -BSPFILE = bsp.pri - - - diff --git a/bsp/src/BEAGLESYNTH/bsp.c b/bsp/src/BEAGLESYNTH/bsp.c deleted file mode 100644 --- a/bsp/src/BEAGLESYNTH/bsp.c +++ /dev/null @@ -1,313 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - -LCD_IF_t lcdIF0={ - .init = &bsp_FSMC_init, - .writereg = &bsp_lcd0_write_reg, - .readreg = &bsp_lcd0_read_reg, - .writeGRAM = &bsp_lcd0_writeGRAM, - .readGRAM = &bsp_lcd0_readGRAM -}; - -LCD_t lcd0={ - .interface = &lcdIF0, - .init = &ili9328init, - .paint = &ili9328paint, - .paintText = &ili9328paintText, - .paintFilRect = &ili9328paintFilRect, - .getPix = &ili9328getPix, - .refreshenable = &ili9328refreshenable, - .width= 240, - .height = 320 -}; - -terminal_t terminal0; - -volatile int16_t* lcd0_CMD=(volatile int16_t*)0x60000000; -volatile int16_t* lcd0_DATA=(volatile int16_t*)0x61FFFFF0; - -float VREF0 =(float)3.3; - -int bsp_init() -{ - int i=0; - for(i=0;i<32;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - bsp_iic_init(); - bsp_FSMC_init(); - bsp_GTerm_init(); - printf("\r=====================\n\r"); - printf( "=====================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf( "=====================\n\r"); - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t gpio1 = gpioopen(LED1); - gpio_t gpio2 = gpioopen(LED2); - gpio_t gpio3 = gpioopen(LED3); - gpio_t gpio4 = gpioopen(PSU_DISABLE); - gpio_t gpio5 = gpioopen(PSU_ALERT_5V); - gpio_t gpio6 = gpioopen(PSU_ALERT_1_5V); - gpio_t gpio7 = gpioopen(PSU_ALERT_3_3V); - gpiosetspeed(&gpio1,gpiohighspeed); - gpiosetspeed(&gpio2,gpiohighspeed); - gpiosetspeed(&gpio3,gpiohighspeed); - gpiosetspeed(&gpio4,gpiohighspeed); - gpiosetspeed(&gpio5,gpiohighspeed); - gpiosetspeed(&gpio6,gpiohighspeed); - gpiosetspeed(&gpio7,gpiohighspeed); - gpioclr(PSU_DISABLE); - gpiosetdir(&gpio1,gpiooutdir); - gpiosetdir(&gpio3,gpiooutdir); - gpiosetdir(&gpio2,gpiooutdir); - gpiosetdir(&gpio4,gpiooutdir); - gpiosetdir(&gpio5,gpioindir); - gpiosetdir(&gpio6,gpioindir); - gpiosetdir(&gpio7,gpioindir); - gpioclr(PSU_DISABLE); -} - -void bsp_uart_init() -{ - //if(__opnfiles__[1]==NULL) - //{ - //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); - // 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; - //} - //else - //{ - uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); - //} -} - - - -int bsp_FSMC_init() -{ -#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) -#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) - - gpio_t gpio1 = gpioopen(LCD_RESET); - gpiosetspeed(&gpio1,gpiohighspeed); - gpiosetdir(&gpio1,gpiooutdir); - gpioclr(LCD_RESET); - - gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10,PE11,PE12,PE13,PE14,PE15\ - ,PD8,PD9,PD10,PD4,PD5,PD7,PE4}; - for(int i=0;i<20;i++) - { - gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); - LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; - gpiosetconfig(&LCD_DBx); - GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); - } - - FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; - FSMC_NORSRAMTimingInitTypeDef p; - - /* Enable FSMC clock */ - RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); - - /*-- FSMC Configuration ------------------------------------------------------*/ - /*----------------------- SRAM Bank 3 ----------------------------------------*/ - /* FSMC_Bank1_NORSRAM4 configuration */ - //p.FSMC_AddressSetupTime = 5; - p.FSMC_AddressSetupTime = 1; - p.FSMC_AddressHoldTime = 0; - //p.FSMC_DataSetupTime = 9; - p.FSMC_DataSetupTime = getCpuFreq()/14545450 ;// 11; - p.FSMC_BusTurnAroundDuration = 0; - p.FSMC_CLKDivision = 0; - p.FSMC_DataLatency = 0; - p.FSMC_AccessMode = FSMC_AccessMode_A; - /* Color LCD configuration ------------------------------------ - LCD configured as follow: - - Data/Address MUX = Disable - - Memory Type = SRAM - - Data Width = 16bit - - Write Operation = Enable - - Extended Mode = Enable - - Asynchronous Wait = Disable */ - - FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; - FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; - FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; - FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; - FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; - FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; - FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; - FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; - FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; - FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; - - FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); - - /* Enable FSMC NOR/SRAM Bank1 */ - FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); - gpioset(LCD_RESET); - lcd0.init(&lcd0); - return 1; -} - -void bsp_spi_init() -{ - -} - - -void bsp_iic_init() -{ - i2copenandconfig(i2c2,0,10000,PF0,PF1); -} - -void bsp_SD_init() -{ - -} - -void vs10XXclearXCS(){} -void vs10XXsetXCS(){} -int vs10XXDREQ() -{ - return 1; -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return 0; -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) -{ - *lcd0_CMD=(uint16_t)reg; - *lcd0_DATA=(uint16_t)data; -} - -uint32_t bsp_lcd0_read_reg(uint32_t reg) -{ - *lcd0_CMD=(uint16_t)reg; - return (uint16_t)*lcd0_DATA; -} - -void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) -{ - *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; - uint16_t* castedBuff=(uint16_t*)buffer; - for(int i=0;i<(int)count;i++) - { - *lcd0_DATA=castedBuff[i]; - } -} - -void bsp_lcd0_readGRAM(void* buffer,uint32_t count) -{ - *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; - uint16_t* castedBuff=(uint16_t*)buffer; - castedBuff[0]=*lcd0_DATA; - for(int i=0;i<(int)count;i++) - { - castedBuff[i]=*lcd0_DATA; - } -} - - -void bsp_GTerm_init() -{ - if(__opnfiles__[1]==NULL) - { - //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); - __opnfiles__[1] = fd1; - } - else - { - - } -} - - - - - - - - - - - - - - - - - diff --git a/bsp/src/BEAGLESYNTH/bsp.h b/bsp/src/BEAGLESYNTH/bsp.h deleted file mode 100644 --- a/bsp/src/BEAGLESYNTH/bsp.h +++ /dev/null @@ -1,106 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -#include -#include -#include -#include - -#define __MAX_OPENED_FILES__ 4 -#define __FS_ROOT_SIZE__ 4 -/* -#ifndef PD8 - #define PD8 -#endif -#ifndef PD9 - #define PD9 -#endif -*/ - - -#define LED1 PF6 -#define LED2 PF7 -#define LED3 PF8 - -#define PSU_DISABLE PH2 -#define PSU_ALERT_5V PF2 -#define PSU_ALERT_1_5V PF3 -#define PSU_ALERT_3_3V PF4 - -#define LCD_RESET PE2 - -extern float VREF0; - -extern uint32_t currentCpuFreq; -extern LCD_t lcd0; - - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); -extern void bsp_GTerm_init(); -extern int bsp_FSMC_init(); - -/* VS1053 */ -extern void clearXCS(); -extern void setXCS(); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); -uint32_t bsp_lcd0_read_reg(uint32_t reg); -void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); -void bsp_lcd0_readGRAM(void *buffer, uint32_t count); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/BEAGLESYNTH/bsp.pri b/bsp/src/BEAGLESYNTH/bsp.pri deleted file mode 100644 --- a/bsp/src/BEAGLESYNTH/bsp.pri +++ /dev/null @@ -1,9 +0,0 @@ -CPU=stm32f4xxxG -DEFINES+=BSP=\\\"BEAGLESYNTH\\\" -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 - -UCMODEL=stm32f4 diff --git a/bsp/src/M4Stick/M4Stick.pro b/bsp/src/M4Stick/M4Stick.pro deleted file mode 100644 --- a/bsp/src/M4Stick/M4Stick.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp - -CONFIG += bsp -BSP=M4Stick - -UCMODEL=stm32f4 - -SOURCES += bsp.c - -HEADERS += bsp.h -LIBS+= -lgpio -luart -li2c -lspi - -BSPFILE = bsp.pri - - - diff --git a/bsp/src/M4Stick/bsp.c b/bsp/src/M4Stick/bsp.c deleted file mode 100644 --- a/bsp/src/M4Stick/bsp.c +++ /dev/null @@ -1,126 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - -float VREF0 =(float)3.3; - -int bsp_init() -{ - int i=0; - for(i=0;i<32;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - printf("\r================================================================\n\r"); - printf("================================================================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf("================================================================\n\r"); - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t gpio1 = gpioopen(PC6);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 - gpio_t gpio2 = gpioopen(PC7);//gpioopen(LED2); - gpiosetspeed(&gpio1,gpiohighspeed); - gpiosetspeed(&gpio2,gpiohighspeed); - gpiosetdir(&gpio1,gpiooutdir); - gpiosetdir(&gpio2,gpiooutdir); -} - -void bsp_uart_init() -{ - if(__opnfiles__[1]==NULL) - { - //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,LED2,LED1,-1,-1); - uartmkstreamdev(uart,fd1); - __opnfiles__[1] = fd1; - } - else - { - uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,LED2,LED1,-1,-1); - } -} - -void bsp_spi_init() -{ - -} - - -void bsp_iic_init() -{ - -} - -void bsp_SD_init() -{ - -} - -void vs10XXclearXCS(){} -void vs10XXsetXCS(){} -int vs10XXDREQ() -{ - return 1; -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return 0; -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - - - - - diff --git a/bsp/src/M4Stick/bsp.h b/bsp/src/M4Stick/bsp.h deleted file mode 100644 --- a/bsp/src/M4Stick/bsp.h +++ /dev/null @@ -1,86 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -#include -#include - - -#define __MAX_OPENED_FILES__ 32 -#define __FS_ROOT_SIZE__ 32 - -#define LED1 PD8 -#define LED2 PD9 - -#define LED3ON GPIOB->BSRRH = GPIO_Pin_15 -#define LED2ON GPIOD->BSRRH = GPIO_Pin_8 -#define LED1ON GPIOD->BSRRH = GPIO_Pin_9 - -#define LED3OFF GPIOB->BSRRL = GPIO_Pin_15 -#define LED2OFF GPIOD->BSRRL = GPIO_Pin_8 -#define LED1OFF GPIOD->BSRRL = GPIO_Pin_9 - -extern float VREF0; - -extern uint32_t currentCpuFreq; - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); - -/* VS1053 */ -extern void clearXCS(); -extern void setXCS(); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/M4Stick/bsp.pri b/bsp/src/M4Stick/bsp.pri deleted file mode 100644 --- a/bsp/src/M4Stick/bsp.pri +++ /dev/null @@ -1,3 +0,0 @@ -CPU=stm32f4xxxG -DEFINES+=BSP=\\\"M4Stick\\\" -UCMODEL=stm32f4 diff --git a/bsp/src/M4StickV2/M4StickV2.pro b/bsp/src/M4StickV2/M4StickV2.pro deleted file mode 100644 --- a/bsp/src/M4StickV2/M4StickV2.pro +++ /dev/null @@ -1,35 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp -CONFIG += bsp - -BSP=M4StickV2 - - -UCMODEL=stm32f4 - -SOURCES += bsp.c - -HEADERS += bsp.h - - -BSPFILE = bsp.pri - - -LIBS+= -lgpio -luart -li2c -lspi - -INCLUDEPATH += $${PWD} - -SOURCES += bsp.c -contains(CONFIG , USB){ -SOURCES += usbd_usr.c \ - usbd_desc.c \ - usbd_cdc_vcp.c \ - usb_bsp.c -} - -HEADERS += $$libuc2/bsp/includes/$$BSP/bsp.h \ - usbd_desc.h \ - usbd_conf.h \ - usbd_cdc_vcp.h \ - usb_conf.h diff --git a/bsp/src/M4StickV2/bsp.c b/bsp/src/M4StickV2/bsp.c deleted file mode 100644 --- a/bsp/src/M4StickV2/bsp.c +++ /dev/null @@ -1,143 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - -float VREF0 =(float)3.3; - -int bsp_init() -{ - int i=0; - for(i=0;i<32;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - bsp_spi_init(); - printf("\r================================================================\n\r"); - printf("================================================================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf("================================================================\n\r"); - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t GPIOList[]={LED1,LED2,LED3,ADC_MODE0,ADC_MODE1,ADC_FSYNC - ,ADC_SYNC,ADC_CLKDIV}; - gpio_t GPIOx; - for(int i=0;i<8;i++) - { - GPIOx = gpioopen(GPIOList[i]); - gpiosetspeed(&GPIOx,gpiohighspeed); - gpiosetdir(&GPIOx,gpiooutdir); - gpiosetouttype(&GPIOx,gpiopushpulltype); - } - gpioset(ADC_CLKDIV); - gpioset(ADC_MODE0); - gpioset(ADC_MODE1); - gpioclr(ADC_SYNC); - gpioclr(ADC_FSYNC); - delay_100us(10); - gpioset(ADC_SYNC); - -} - -void bsp_uart_init() -{ - if(__opnfiles__[1]==NULL) - { - //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - //uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,230400,PA9,PA10,-1,-1); - uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); - uartmkstreamdev(uart,fd1); - __opnfiles__[1] = fd1; - } - else - { - // uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,230400,PA9,PA10,-1,-1); - uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); - } -} - -void bsp_spi_init() -{ - spiopenandconfig(spi1,spi8bits | spimaster |spiclkinhlow | spiclkfirstedge | spimsbfirst,4000000,DAC_DIN,ADC_DOUT1,ADC_SCLK,-1); -} - - -void bsp_iic_init() -{ - -} - -void bsp_SD_init() -{ - -} - -void vs10XXclearXCS(){} -void vs10XXsetXCS(){} -int vs10XXDREQ() -{ - return 1; -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return 0; -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - - - - - diff --git a/bsp/src/M4StickV2/bsp.h b/bsp/src/M4StickV2/bsp.h deleted file mode 100644 --- a/bsp/src/M4StickV2/bsp.h +++ /dev/null @@ -1,92 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -#include -#include - - -#define __MAX_OPENED_FILES__ 32 -#define __FS_ROOT_SIZE__ 32 - -#define LED1 PD9 -#define LED2 PD8 -#define LED3 PB15 - -#define DAC_CS PA1 -#define DAC_DIN PA7 - -#define ADC_MODE0 PA2 -#define ADC_MODE1 PA3 -#define ADC_FSYNC PA4 -#define ADC_SCLK PA5 -#define ADC_DOUT1 PA6 - -#define ADC_SYNC PB10 -#define ADC_CLKDIV PB11 - - -extern float VREF0; - -extern uint32_t currentCpuFreq; - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); - -/* VS1053 */ -extern void clearXCS(); -extern void setXCS(); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/M4StickV2/bsp.pri b/bsp/src/M4StickV2/bsp.pri deleted file mode 100644 --- a/bsp/src/M4StickV2/bsp.pri +++ /dev/null @@ -1,7 +0,0 @@ -CPU=stm32f4xxxG -DEFINES+=BSP=\\\"M4StickV2\\\" -#CONFIG += USB -USB += cdc -DEFINES+= USE_USB_OTG_FS -DEFINES+=stm32f4 -UCMODEL=stm32f4 diff --git a/bsp/src/M4StickV2/usb_bsp.c b/bsp/src/M4StickV2/usb_bsp.c deleted file mode 100644 --- a/bsp/src/M4StickV2/usb_bsp.c +++ /dev/null @@ -1,320 +0,0 @@ -/** - ****************************************************************************** - * @file usb_bsp.c - * @author MCD Application Team - * @version V1.1.0 - * @date 19-March-2012 - * @brief This file is responsible to offer board support package and is - * configurable by user. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2012 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "usb_bsp.h" -#include "usbd_conf.h" - -/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY -* @{ -*/ - -/** @defgroup USB_BSP -* @brief This file is responsible to offer board support package -* @{ -*/ - -/** @defgroup USB_BSP_Private_Defines -* @{ -*/ -/** -* @} -*/ - - -/** @defgroup USB_BSP_Private_TypesDefinitions -* @{ -*/ -/** -* @} -*/ - - - - - -/** @defgroup USB_BSP_Private_Macros -* @{ -*/ -/** -* @} -*/ - -/** @defgroup USBH_BSP_Private_Variables -* @{ -*/ - -/** -* @} -*/ - -/** @defgroup USBH_BSP_Private_FunctionPrototypes -* @{ -*/ -/** -* @} -*/ - -/** @defgroup USB_BSP_Private_Functions -* @{ -*/ - - -/** -* @brief USB_OTG_BSP_Init -* Initilizes BSP configurations -* @param None -* @retval None -*/ - -void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev) -{ -#ifdef USE_STM3210C_EVAL - - RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3); - RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ; - -#else // USE_STM322xG_EVAL - GPIO_InitTypeDef GPIO_InitStructure; - #ifdef USE_USB_OTG_FS - RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA , ENABLE); - - /* Configure SOF ID DM DP Pins */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | - GPIO_Pin_11 | - GPIO_Pin_12; - - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; - GPIO_Init(GPIOA, &GPIO_InitStructure); - - GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_OTG1_FS) ; - GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_OTG1_FS) ; - GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_OTG1_FS) ; - - /* Configure VBUS Pin */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; - GPIO_Init(GPIOA, &GPIO_InitStructure); - - /* Configure ID pin */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; - GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_Init(GPIOA, &GPIO_InitStructure); - GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_OTG1_FS) ; - - RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); - RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ; - #else // USE_USB_OTG_HS - - #ifdef USE_ULPI_PHY // ULPI - RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | - RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOH | - RCC_AHB1Periph_GPIOI, ENABLE); - - - GPIO_PinAFConfig(GPIOA,GPIO_PinSource3, GPIO_AF_OTG2_HS) ; // D0 - GPIO_PinAFConfig(GPIOA,GPIO_PinSource5, GPIO_AF_OTG2_HS) ; // CLK - GPIO_PinAFConfig(GPIOB,GPIO_PinSource0, GPIO_AF_OTG2_HS) ; // D1 - GPIO_PinAFConfig(GPIOB,GPIO_PinSource1, GPIO_AF_OTG2_HS) ; // D2 - GPIO_PinAFConfig(GPIOB,GPIO_PinSource5, GPIO_AF_OTG2_HS) ; // D7 - GPIO_PinAFConfig(GPIOB,GPIO_PinSource10,GPIO_AF_OTG2_HS) ; // D3 - GPIO_PinAFConfig(GPIOB,GPIO_PinSource11,GPIO_AF_OTG2_HS) ; // D4 - GPIO_PinAFConfig(GPIOB,GPIO_PinSource12,GPIO_AF_OTG2_HS) ; // D5 - GPIO_PinAFConfig(GPIOB,GPIO_PinSource13,GPIO_AF_OTG2_HS) ; // D6 - GPIO_PinAFConfig(GPIOH,GPIO_PinSource4, GPIO_AF_OTG2_HS) ; // NXT - GPIO_PinAFConfig(GPIOI,GPIO_PinSource11,GPIO_AF_OTG2_HS) ; // DIR - GPIO_PinAFConfig(GPIOC,GPIO_PinSource0, GPIO_AF_OTG2_HS) ; // STP - - // CLK - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 ; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_Init(GPIOA, &GPIO_InitStructure); - - // D0 - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 ; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; - GPIO_Init(GPIOA, &GPIO_InitStructure); - - - - // D1 D2 D3 D4 D5 D6 D7 - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | - GPIO_Pin_5 | GPIO_Pin_10 | - GPIO_Pin_11| GPIO_Pin_12 | - GPIO_Pin_13 ; - - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; - GPIO_Init(GPIOB, &GPIO_InitStructure); - - - // STP - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - //NXT - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_Init(GPIOH, &GPIO_InitStructure); - - - //DIR - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_Init(GPIOI, &GPIO_InitStructure); - - - RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS | - RCC_AHB1Periph_OTG_HS_ULPI, ENABLE) ; - - #else - - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB , ENABLE); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | - GPIO_Pin_14 | - GPIO_Pin_15; - - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_Init(GPIOB, &GPIO_InitStructure); - - GPIO_PinAFConfig(GPIOB,GPIO_PinSource12, GPIO_AF_OTG2_FS) ; - GPIO_PinAFConfig(GPIOB,GPIO_PinSource14,GPIO_AF_OTG2_FS) ; - GPIO_PinAFConfig(GPIOB,GPIO_PinSource15,GPIO_AF_OTG2_FS) ; - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_Init(GPIOB, &GPIO_InitStructure); - - - RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS, ENABLE) ; - - #endif - #endif //USB_OTG_HS -#endif //USE_STM322xG_EVAL -} -/** -* @brief USB_OTG_BSP_EnableInterrupt -* Enabele USB Global interrupt -* @param None -* @retval None -*/ -void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev) -{ - NVIC_InitTypeDef NVIC_InitStructure; - - NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); -#ifdef USE_USB_OTG_HS - NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_IRQn; -#else - NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; -#endif - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_Init(&NVIC_InitStructure); -#ifdef USB_OTG_HS_DEDICATED_EP1_ENABLED - NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); - NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_EP1_OUT_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_Init(&NVIC_InitStructure); - - NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); - NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_EP1_IN_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_Init(&NVIC_InitStructure); -#endif -} -/** -* @brief USB_OTG_BSP_uDelay -* This function provides delay time in micro sec -* @param usec : Value of delay required in micro sec -* @retval None -*/ -void USB_OTG_BSP_uDelay (const uint32_t usec) -{ - uint32_t count = 0; - const uint32_t utime = (120 * usec / 7); - do - { - if ( ++count > utime ) - { - return ; - } - } - while (1); -} - - -/** -* @brief USB_OTG_BSP_mDelay -* This function provides delay time in milli sec -* @param msec : Value of delay required in milli sec -* @retval None -*/ -void USB_OTG_BSP_mDelay (const uint32_t msec) -{ - USB_OTG_BSP_uDelay(msec * 1000); -} -/** -* @} -*/ - -/** -* @} -*/ - -/** -* @} -*/ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/src/M4StickV2/usb_conf.h b/bsp/src/M4StickV2/usb_conf.h deleted file mode 100644 --- a/bsp/src/M4StickV2/usb_conf.h +++ /dev/null @@ -1,310 +0,0 @@ -/** - ****************************************************************************** - * @file usb_conf.h - * @author MCD Application Team - * @version V1.1.0 - * @date 19-March-2012 - * @brief General low level driver configuration - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2012 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_CONF__H__ -#define __USB_CONF__H__ - -/* Includes ------------------------------------------------------------------*/ -#if defined (USE_STM322xG_EVAL) - #include "stm322xg_eval.h" - #include "stm322xg_eval_lcd.h" - #include "stm322xg_eval_ioe.h" - #include "stm322xg_eval_sdio_sd.h" -#elif defined(USE_STM324xG_EVAL) - #include "stm32f4xx.h" - #include "stm324xg_eval.h" - #include "stm324xg_eval_lcd.h" - #include "stm324xg_eval_ioe.h" - #include "stm324xg_eval_sdio_sd.h" -#elif defined (USE_STM3210C_EVAL) - #include "stm32f10x.h" - #include "stm3210c_eval.h" - #include "stm3210c_eval_lcd.h" - #include "stm3210c_eval_ioe.h" - #include "stm3210c_eval_spi_sd.h" -#elif defined (stm32f4) - #include "stm32f4xx.h" -#else - #error "Missing define: Evaluation board (ie. USE_STM322xG_EVAL)" -#endif - - -/** @addtogroup USB_OTG_DRIVER - * @{ - */ - -/** @defgroup USB_CONF - * @brief USB low level driver configuration file - * @{ - */ - -/** @defgroup USB_CONF_Exported_Defines - * @{ - */ - -/* USB Core and PHY interface configuration. - Tip: To avoid modifying these defines each time you need to change the USB - configuration, you can declare the needed define in your toolchain - compiler preprocessor. - */ -/****************** USB OTG FS PHY CONFIGURATION ******************************* -* The USB OTG FS Core supports one on-chip Full Speed PHY. -* -* The USE_EMBEDDED_PHY symbol is defined in the project compiler preprocessor -* when FS core is used. -*******************************************************************************/ -#ifndef USE_USB_OTG_FS - //#define USE_USB_OTG_FS -#endif /* USE_USB_OTG_FS */ - -#ifdef USE_USB_OTG_FS - #define USB_OTG_FS_CORE -#endif - -/****************** USB OTG HS PHY CONFIGURATION ******************************* -* The USB OTG HS Core supports two PHY interfaces: -* (i) An ULPI interface for the external High Speed PHY: the USB HS Core will -* operate in High speed mode -* (ii) An on-chip Full Speed PHY: the USB HS Core will operate in Full speed mode -* -* You can select the PHY to be used using one of these two defines: -* (i) USE_ULPI_PHY: if the USB OTG HS Core is to be used in High speed mode -* (ii) USE_EMBEDDED_PHY: if the USB OTG HS Core is to be used in Full speed mode -* -* Notes: -* - The USE_ULPI_PHY symbol is defined in the project compiler preprocessor as -* default PHY when HS core is used. -* - On STM322xG-EVAL and STM324xG-EVAL boards, only configuration(i) is available. -* Configuration (ii) need a different hardware, for more details refer to your -* STM32 device datasheet. -*******************************************************************************/ -#ifndef USE_USB_OTG_HS - //#define USE_USB_OTG_HS -#endif /* USE_USB_OTG_HS */ - -#ifndef USE_ULPI_PHY - //#define USE_ULPI_PHY -#endif /* USE_ULPI_PHY */ - -#ifndef USE_EMBEDDED_PHY - //#define USE_EMBEDDED_PHY -#endif /* USE_EMBEDDED_PHY */ - -#ifdef USE_USB_OTG_HS - #define USB_OTG_HS_CORE -#endif - -/******************************************************************************* -* FIFO Size Configuration in Device mode -* -* (i) Receive data FIFO size = RAM for setup packets + -* OUT endpoint control information + -* data OUT packets + miscellaneous -* Space = ONE 32-bits words -* --> RAM for setup packets = 10 spaces -* (n is the nbr of CTRL EPs the device core supports) -* --> OUT EP CTRL info = 1 space -* (one space for status information written to the FIFO along with each -* received packet) -* --> data OUT packets = (Largest Packet Size / 4) + 1 spaces -* (MINIMUM to receive packets) -* --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces -* (if high-bandwidth EP is enabled or multiple isochronous EPs) -* --> miscellaneous = 1 space per OUT EP -* (one space for transfer complete status information also pushed to the -* FIFO with each endpoint's last packet) -* -* (ii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for -* that particular IN EP. More space allocated in the IN EP Tx FIFO results -* in a better performance on the USB and can hide latencies on the AHB. -* -* (iii) TXn min size = 16 words. (n : Transmit FIFO index) -* (iv) When a TxFIFO is not used, the Configuration should be as follows: -* case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) -* --> Txm can use the space allocated for Txn. -* case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) -* --> Txn should be configured with the minimum space of 16 words -* (v) The FIFO is used optimally when used TxFIFOs are allocated in the top -* of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. -* (vi) In HS case 12 FIFO locations should be reserved for internal DMA registers -* so total FIFO size should be 1012 Only instead of 1024 -*******************************************************************************/ - -/****************** USB OTG HS CONFIGURATION **********************************/ -#ifdef USB_OTG_HS_CORE - #define RX_FIFO_HS_SIZE 512 - #define TX0_FIFO_HS_SIZE 64 - #define TX1_FIFO_HS_SIZE 372 - #define TX2_FIFO_HS_SIZE 64 - #define TX3_FIFO_HS_SIZE 0 - #define TX4_FIFO_HS_SIZE 0 - #define TX5_FIFO_HS_SIZE 0 - -// #define USB_OTG_HS_SOF_OUTPUT_ENABLED - - #ifdef USE_ULPI_PHY - #define USB_OTG_ULPI_PHY_ENABLED - #endif - #ifdef USE_EMBEDDED_PHY - #define USB_OTG_EMBEDDED_PHY_ENABLED - /* wakeup is working only when HS core is configured in FS mode */ - #define USB_OTG_HS_LOW_PWR_MGMT_SUPPORT - #endif - /* #define USB_OTG_HS_INTERNAL_DMA_ENABLED */ /* Be aware that enabling DMA mode will result in data being sent only by - multiple of 4 packet sizes. This is due to the fact that USB DMA does - not allow sending data from non word-aligned addresses. - For this specific application, it is advised to not enable this option - unless required. */ - #define USB_OTG_HS_DEDICATED_EP1_ENABLED -#endif - -/****************** USB OTG FS CONFIGURATION **********************************/ -#ifdef USB_OTG_FS_CORE - #define RX_FIFO_FS_SIZE 128 - #define TX0_FIFO_FS_SIZE 32 - #define TX1_FIFO_FS_SIZE 128 - #define TX2_FIFO_FS_SIZE 32 - #define TX3_FIFO_FS_SIZE 0 - -// #define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT -// #define USB_OTG_FS_SOF_OUTPUT_ENABLED -#endif - -/****************** USB OTG MISC CONFIGURATION ********************************/ -#define VBUS_SENSING_ENABLED - -/****************** USB OTG MODE CONFIGURATION ********************************/ -//#define USE_HOST_MODE -#define USE_DEVICE_MODE -//#define USE_OTG_MODE - -#ifndef USB_OTG_FS_CORE - #ifndef USB_OTG_HS_CORE - #error "USB_OTG_HS_CORE or USB_OTG_FS_CORE should be defined" - #endif -#endif - -#ifndef USE_DEVICE_MODE - #ifndef USE_HOST_MODE - #error "USE_DEVICE_MODE or USE_HOST_MODE should be defined" - #endif -#endif - -#ifndef USE_USB_OTG_HS - #ifndef USE_USB_OTG_FS - #error "USE_USB_OTG_HS or USE_USB_OTG_FS should be defined" - #endif -#else //USE_USB_OTG_HS - #ifndef USE_ULPI_PHY - #ifndef USE_EMBEDDED_PHY - #error "USE_ULPI_PHY or USE_EMBEDDED_PHY should be defined" - #endif - #endif -#endif - -/****************** C Compilers dependant keywords ****************************/ -/* In HS mode and when the DMA is used, all variables and data structures dealing - with the DMA during the transaction process should be 4-bytes aligned */ -#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED - #if defined (__GNUC__) /* GNU Compiler */ - #define __ALIGN_END __attribute__ ((aligned (4))) - #define __ALIGN_BEGIN - #else - #define __ALIGN_END - #if defined (__CC_ARM) /* ARM Compiler */ - #define __ALIGN_BEGIN __align(4) - #elif defined (__ICCARM__) /* IAR Compiler */ - #define __ALIGN_BEGIN - #elif defined (__TASKING__) /* TASKING Compiler */ - #define __ALIGN_BEGIN __align(4) - #endif /* __CC_ARM */ - #endif /* __GNUC__ */ -#else - #define __ALIGN_BEGIN - #define __ALIGN_END -#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ - -/* __packed keyword used to decrease the data type alignment to 1-byte */ -#if defined (__CC_ARM) /* ARM Compiler */ - #define __packed __packed -#elif defined (__ICCARM__) /* IAR Compiler */ - #define __packed __packed -#elif defined ( __GNUC__ ) /* GNU Compiler */ - #define __packed __attribute__ ((__packed__)) -#elif defined (__TASKING__) /* TASKING Compiler */ - #define __packed __unaligned -#endif /* __CC_ARM */ - -/** - * @} - */ - - -/** @defgroup USB_CONF_Exported_Types - * @{ - */ -/** - * @} - */ - - -/** @defgroup USB_CONF_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup USB_CONF_Exported_Variables - * @{ - */ -/** - * @} - */ - -/** @defgroup USB_CONF_Exported_FunctionsPrototype - * @{ - */ -/** - * @} - */ - - -#endif //__USB_CONF__H__ - - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/bsp/src/M4StickV2/usbd_cdc_vcp.c b/bsp/src/M4StickV2/usbd_cdc_vcp.c deleted file mode 100644 --- a/bsp/src/M4StickV2/usbd_cdc_vcp.c +++ /dev/null @@ -1,381 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_cdc_vcp.c - * @author MCD Application Team - * @version V1.1.0 - * @date 19-March-2012 - * @brief Generic media access Layer. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2012 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED -#pragma data_alignment = 4 -#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_cdc_vcp.h" -#include "usb_conf.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -LINE_CODING linecoding = - { - 115200, /* baud rate*/ - 0x00, /* stop bits-1*/ - 0x00, /* parity - none*/ - 0x08 /* nb. of bits 8*/ - }; - - -USART_InitTypeDef USART_InitStructure; - -/* These are external variables imported from CDC core to be used for IN - transfer management. */ -extern uint8_t APP_Rx_Buffer []; /* Write CDC received data in this buffer. - These data will be sent over USB IN endpoint - in the CDC core functions. */ -extern uint32_t APP_Rx_ptr_in; /* Increment this pointer or roll it back to - start address when writing received data - in the buffer APP_Rx_Buffer. */ - -/* Private function prototypes -----------------------------------------------*/ -static uint16_t VCP_Init (void); -static uint16_t VCP_DeInit (void); -static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len); -static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len); -static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len); - -static uint16_t VCP_COMConfig(uint8_t Conf); - -CDC_IF_Prop_TypeDef VCP_fops = -{ - VCP_Init, - VCP_DeInit, - VCP_Ctrl, - VCP_DataTx, - VCP_DataRx -}; - -/* Private functions ---------------------------------------------------------*/ -/** - * @brief VCP_Init - * Initializes the Media on the STM32 - * @param None - * @retval Result of the opeartion (USBD_OK in all cases) - */ -static uint16_t VCP_Init(void) -{ - NVIC_InitTypeDef NVIC_InitStructure; - - /* EVAL_COM1 default configuration */ - /* EVAL_COM1 configured as follow: - - BaudRate = 115200 baud - - Word Length = 8 Bits - - One Stop Bit - - Parity Odd - - Hardware flow control disabled - - Receive and transmit enabled - */ - USART_InitStructure.USART_BaudRate = 115200; - USART_InitStructure.USART_WordLength = USART_WordLength_8b; - USART_InitStructure.USART_StopBits = USART_StopBits_1; - USART_InitStructure.USART_Parity = USART_Parity_Odd; - USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; - USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; - - /* Configure and enable the USART */ - STM_EVAL_COMInit(COM1, &USART_InitStructure); - - /* Enable the USART Receive interrupt */ - USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); - - /* Enable USART Interrupt */ - NVIC_InitStructure.NVIC_IRQChannel = EVAL_COM1_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_Init(&NVIC_InitStructure); - - return USBD_OK; -} - -/** - * @brief VCP_DeInit - * DeInitializes the Media on the STM32 - * @param None - * @retval Result of the opeartion (USBD_OK in all cases) - */ -static uint16_t VCP_DeInit(void) -{ - - return USBD_OK; -} - - -/** - * @brief VCP_Ctrl - * Manage the CDC class requests - * @param Cmd: Command code - * @param Buf: Buffer containing command data (request parameters) - * @param Len: Number of data to be sent (in bytes) - * @retval Result of the opeartion (USBD_OK in all cases) - */ -static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len) -{ - switch (Cmd) - { - case SEND_ENCAPSULATED_COMMAND: - /* Not needed for this driver */ - break; - - case GET_ENCAPSULATED_RESPONSE: - /* Not needed for this driver */ - break; - - case SET_COMM_FEATURE: - /* Not needed for this driver */ - break; - - case GET_COMM_FEATURE: - /* Not needed for this driver */ - break; - - case CLEAR_COMM_FEATURE: - /* Not needed for this driver */ - break; - - case SET_LINE_CODING: - linecoding.bitrate = (uint32_t)(Buf[0] | (Buf[1] << 8) | (Buf[2] << 16) | (Buf[3] << 24)); - linecoding.format = Buf[4]; - linecoding.paritytype = Buf[5]; - linecoding.datatype = Buf[6]; - /* Set the new configuration */ - VCP_COMConfig(OTHER_CONFIG); - break; - - case GET_LINE_CODING: - Buf[0] = (uint8_t)(linecoding.bitrate); - Buf[1] = (uint8_t)(linecoding.bitrate >> 8); - Buf[2] = (uint8_t)(linecoding.bitrate >> 16); - Buf[3] = (uint8_t)(linecoding.bitrate >> 24); - Buf[4] = linecoding.format; - Buf[5] = linecoding.paritytype; - Buf[6] = linecoding.datatype; - break; - - case SET_CONTROL_LINE_STATE: - /* Not needed for this driver */ - break; - - case SEND_BREAK: - /* Not needed for this driver */ - break; - - default: - break; - } - - return USBD_OK; -} - -/** - * @brief VCP_DataTx - * CDC received data to be send over USB IN endpoint are managed in - * this function. - * @param Buf: Buffer of data to be sent - * @param Len: Number of data to be sent (in bytes) - * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL - */ -static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len) -{ - if (linecoding.datatype == 7) - { - APP_Rx_Buffer[APP_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1) & 0x7F; - } - else if (linecoding.datatype == 8) - { - APP_Rx_Buffer[APP_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1); - } - - APP_Rx_ptr_in++; - - /* To avoid buffer overflow */ - if(APP_Rx_ptr_in == APP_RX_DATA_SIZE) - { - APP_Rx_ptr_in = 0; - } - - return USBD_OK; -} - -/** - * @brief VCP_DataRx - * Data received over USB OUT endpoint are sent over CDC interface - * through this function. - * - * @note - * This function will block any OUT packet reception on USB endpoint - * untill exiting this function. If you exit this function before transfer - * is complete on CDC interface (ie. using DMA controller) it will result - * in receiving more data while previous ones are still not sent. - * - * @param Buf: Buffer of data to be received - * @param Len: Number of data received (in bytes) - * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL - */ -static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len) -{ - uint32_t i; - - for (i = 0; i < Len; i++) - { - USART_SendData(EVAL_COM1, *(Buf + i) ); - while(USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TXE) == RESET); - } - - return USBD_OK; -} - -/** - * @brief VCP_COMConfig - * Configure the COM Port with default values or values received from host. - * @param Conf: can be DEFAULT_CONFIG to set the default configuration or OTHER_CONFIG - * to set a configuration received from the host. - * @retval None. - */ -static uint16_t VCP_COMConfig(uint8_t Conf) -{ - if (Conf == DEFAULT_CONFIG) - { - /* EVAL_COM1 default configuration */ - /* EVAL_COM1 configured as follow: - - BaudRate = 115200 baud - - Word Length = 8 Bits - - One Stop Bit - - Parity Odd - - Hardware flow control disabled - - Receive and transmit enabled - */ - USART_InitStructure.USART_BaudRate = 115200; - USART_InitStructure.USART_WordLength = USART_WordLength_8b; - USART_InitStructure.USART_StopBits = USART_StopBits_1; - USART_InitStructure.USART_Parity = USART_Parity_Odd; - USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; - USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; - - /* Configure and enable the USART */ - STM_EVAL_COMInit(COM1, &USART_InitStructure); - - /* Enable the USART Receive interrupt */ - USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); - } - else - { - /* set the Stop bit*/ - switch (linecoding.format) - { - case 0: - USART_InitStructure.USART_StopBits = USART_StopBits_1; - break; - case 1: - USART_InitStructure.USART_StopBits = USART_StopBits_1_5; - break; - case 2: - USART_InitStructure.USART_StopBits = USART_StopBits_2; - break; - default : - VCP_COMConfig(DEFAULT_CONFIG); - return (USBD_FAIL); - } - - /* set the parity bit*/ - switch (linecoding.paritytype) - { - case 0: - USART_InitStructure.USART_Parity = USART_Parity_No; - break; - case 1: - USART_InitStructure.USART_Parity = USART_Parity_Even; - break; - case 2: - USART_InitStructure.USART_Parity = USART_Parity_Odd; - break; - default : - VCP_COMConfig(DEFAULT_CONFIG); - return (USBD_FAIL); - } - - /*set the data type : only 8bits and 9bits is supported */ - switch (linecoding.datatype) - { - case 0x07: - /* With this configuration a parity (Even or Odd) should be set */ - USART_InitStructure.USART_WordLength = USART_WordLength_8b; - break; - case 0x08: - if (USART_InitStructure.USART_Parity == USART_Parity_No) - { - USART_InitStructure.USART_WordLength = USART_WordLength_8b; - } - else - { - USART_InitStructure.USART_WordLength = USART_WordLength_9b; - } - - break; - default : - VCP_COMConfig(DEFAULT_CONFIG); - return (USBD_FAIL); - } - - USART_InitStructure.USART_BaudRate = linecoding.bitrate; - USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; - USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; - - /* Configure and enable the USART */ - STM_EVAL_COMInit(COM1, &USART_InitStructure); - } - return USBD_OK; -} - -/** - * @brief EVAL_COM_IRQHandler - * - * @param None. - * @retval None. - */ -void EVAL_COM_IRQHandler(void) -{ - if (USART_GetITStatus(EVAL_COM1, USART_IT_RXNE) != RESET) - { - /* Send the received data to the PC Host*/ - VCP_DataTx (0,0); - } - - /* If overrun condition occurs, clear the ORE flag and recover communication */ - if (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_ORE) != RESET) - { - (void)USART_ReceiveData(EVAL_COM1); - } -} - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/src/M4StickV2/usbd_cdc_vcp.h b/bsp/src/M4StickV2/usbd_cdc_vcp.h deleted file mode 100644 --- a/bsp/src/M4StickV2/usbd_cdc_vcp.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_cdc_vcp.h - * @author MCD Application Team - * @version V1.1.0 - * @date 19-March-2012 - * @brief Header for usbd_cdc_vcp.c file. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2012 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USBD_CDC_VCP_H -#define __USBD_CDC_VCP_H - -/* Includes ------------------------------------------------------------------*/ -#ifdef STM32F2XX - #include "stm32f2xx.h" -#elif defined(STM32F10X_CL) - #include "stm32f10x.h" -#endif /* STM32F2XX */ - -#include "usbd_cdc_core.h" -#include "usbd_conf.h" - - -/* Exported typef ------------------------------------------------------------*/ -/* The following structures groups all needed parameters to be configured for the - ComPort. These parameters can modified on the fly by the host through CDC class - command class requests. */ -typedef struct -{ - uint32_t bitrate; - uint8_t format; - uint8_t paritytype; - uint8_t datatype; -}LINE_CODING; - -/* Exported constants --------------------------------------------------------*/ -/* The following define is used to route the USART IRQ handler to be used. - The IRQ handler function is implemented in the usbd_cdc_vcp.c file. */ - -#ifdef USE_STM3210C_EVAL - #define EVAL_COM_IRQHandler USART2_IRQHandler -#else - #define EVAL_COM_IRQHandler USART3_IRQHandler -#endif /* USE_STM322xG_EVAL */ - - -#define DEFAULT_CONFIG 0 -#define OTHER_CONFIG 1 - -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ - -#endif /* __USBD_CDC_VCP_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/src/M4StickV2/usbd_conf.h b/bsp/src/M4StickV2/usbd_conf.h deleted file mode 100644 --- a/bsp/src/M4StickV2/usbd_conf.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_conf.h - * @author MCD Application Team - * @version V1.1.0 - * @date 19-March-2012 - * @brief USB Device configuration file - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2012 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USBD_CONF__H__ -#define __USBD_CONF__H__ - -/* Includes ------------------------------------------------------------------*/ -#include "usb_conf.h" - -/** @defgroup USB_CONF_Exported_Defines - * @{ - */ -#define USBD_CFG_MAX_NUM 1 -#define USBD_ITF_MAX_NUM 1 - -#define USBD_SELF_POWERED - -#define USB_MAX_STR_DESC_SIZ 255 - -/** @defgroup USB_VCP_Class_Layer_Parameter - * @{ - */ -#define CDC_IN_EP 0x81 /* EP1 for data IN */ -#define CDC_OUT_EP 0x01 /* EP1 for data OUT */ -#define CDC_CMD_EP 0x82 /* EP2 for CDC commands */ - -/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ -#ifdef USE_USB_OTG_HS - #define CDC_DATA_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */ - #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ - - #define CDC_IN_FRAME_INTERVAL 40 /* Number of micro-frames between IN transfers */ - #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer: - APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL*8 */ -#else - #define CDC_DATA_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */ - #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ - - #define CDC_IN_FRAME_INTERVAL 5 /* Number of frames between IN transfers */ - #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer: - APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL */ -#endif /* USE_USB_OTG_HS */ - -#define APP_FOPS VCP_fops -/** - * @} - */ - -/** @defgroup USB_CONF_Exported_Types - * @{ - */ -/** - * @} - */ - - -/** @defgroup USB_CONF_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup USB_CONF_Exported_Variables - * @{ - */ -/** - * @} - */ - -/** @defgroup USB_CONF_Exported_FunctionsPrototype - * @{ - */ -/** - * @} - */ - - -#endif //__USBD_CONF__H__ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/bsp/src/M4StickV2/usbd_desc.c b/bsp/src/M4StickV2/usbd_desc.c deleted file mode 100644 --- a/bsp/src/M4StickV2/usbd_desc.c +++ /dev/null @@ -1,322 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_desc.c - * @author MCD Application Team - * @version V1.1.0 - * @date 19-March-2012 - * @brief This file provides the USBD descriptors and string formating method. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2012 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_core.h" -#include "usbd_desc.h" -#include "usbd_req.h" -#include "usbd_conf.h" -#include "usb_regs.h" - -/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY - * @{ - */ - - -/** @defgroup USBD_DESC - * @brief USBD descriptors module - * @{ - */ - -/** @defgroup USBD_DESC_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - - -/** @defgroup USBD_DESC_Private_Defines - * @{ - */ -#define USBD_VID 0x0483 - -#define USBD_PID 0x5740 - -/** @defgroup USB_String_Descriptors - * @{ - */ -#define USBD_LANGID_STRING 0x409 -#define USBD_MANUFACTURER_STRING "STMicroelectronics" - -#define USBD_PRODUCT_HS_STRING "STM32 Virtual ComPort in HS mode" -#define USBD_SERIALNUMBER_HS_STRING "00000000050B" - -#define USBD_PRODUCT_FS_STRING "STM32 Virtual ComPort in FS Mode" -#define USBD_SERIALNUMBER_FS_STRING "00000000050C" - -#define USBD_CONFIGURATION_HS_STRING "VCP Config" -#define USBD_INTERFACE_HS_STRING "VCP Interface" - -#define USBD_CONFIGURATION_FS_STRING "VCP Config" -#define USBD_INTERFACE_FS_STRING "VCP Interface" -/** - * @} - */ - - -/** @defgroup USBD_DESC_Private_Macros - * @{ - */ -/** - * @} - */ - - -/** @defgroup USBD_DESC_Private_Variables - * @{ - */ - -USBD_DEVICE USR_desc = -{ - USBD_USR_DeviceDescriptor, - USBD_USR_LangIDStrDescriptor, - USBD_USR_ManufacturerStrDescriptor, - USBD_USR_ProductStrDescriptor, - USBD_USR_SerialStrDescriptor, - USBD_USR_ConfigStrDescriptor, - USBD_USR_InterfaceStrDescriptor, - -}; - -#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED - #if defined ( __ICCARM__ ) /*!< IAR Compiler */ - #pragma data_alignment=4 - #endif -#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ -/* USB Standard Device Descriptor */ -__ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = - { - 0x12, /*bLength */ - USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ - 0x00, /*bcdUSB */ - 0x02, - 0x00, /*bDeviceClass*/ - 0x00, /*bDeviceSubClass*/ - 0x00, /*bDeviceProtocol*/ - USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/ - LOBYTE(USBD_VID), /*idVendor*/ - HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID), /*idVendor*/ - HIBYTE(USBD_PID), /*idVendor*/ - 0x00, /*bcdDevice rel. 2.00*/ - 0x02, - USBD_IDX_MFC_STR, /*Index of manufacturer string*/ - USBD_IDX_PRODUCT_STR, /*Index of product string*/ - USBD_IDX_SERIAL_STR, /*Index of serial number string*/ - USBD_CFG_MAX_NUM /*bNumConfigurations*/ - } ; /* USB_DeviceDescriptor */ - -#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED - #if defined ( __ICCARM__ ) /*!< IAR Compiler */ - #pragma data_alignment=4 - #endif -#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ -/* USB Standard Device Descriptor */ -__ALIGN_BEGIN uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = -{ - USB_LEN_DEV_QUALIFIER_DESC, - USB_DESC_TYPE_DEVICE_QUALIFIER, - 0x00, - 0x02, - 0x00, - 0x00, - 0x00, - 0x40, - 0x01, - 0x00, -}; - -#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED - #if defined ( __ICCARM__ ) /*!< IAR Compiler */ - #pragma data_alignment=4 - #endif -#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ -/* USB Standard Device Descriptor */ -__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END = -{ - USB_SIZ_STRING_LANGID, - USB_DESC_TYPE_STRING, - LOBYTE(USBD_LANGID_STRING), - HIBYTE(USBD_LANGID_STRING), -}; -/** - * @} - */ - - -/** @defgroup USBD_DESC_Private_FunctionPrototypes - * @{ - */ -/** - * @} - */ - - -/** @defgroup USBD_DESC_Private_Functions - * @{ - */ - -/** -* @brief USBD_USR_DeviceDescriptor -* return the device descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length) -{ - *length = sizeof(USBD_DeviceDesc); - return USBD_DeviceDesc; -} - -/** -* @brief USBD_USR_LangIDStrDescriptor -* return the LangID string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length) -{ - *length = sizeof(USBD_LangIDDesc); - return USBD_LangIDDesc; -} - - -/** -* @brief USBD_USR_ProductStrDescriptor -* return the product string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_ProductStrDescriptor( uint8_t speed , uint16_t *length) -{ - - - if(speed == 0) - { - USBD_GetString (USBD_PRODUCT_HS_STRING, USBD_StrDesc, length); - } - else - { - USBD_GetString (USBD_PRODUCT_FS_STRING, USBD_StrDesc, length); - } - return USBD_StrDesc; -} - -/** -* @brief USBD_USR_ManufacturerStrDescriptor -* return the manufacturer string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_ManufacturerStrDescriptor( uint8_t speed , uint16_t *length) -{ - USBD_GetString (USBD_MANUFACTURER_STRING, USBD_StrDesc, length); - return USBD_StrDesc; -} - -/** -* @brief USBD_USR_SerialStrDescriptor -* return the serial number string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length) -{ - if(speed == USB_OTG_SPEED_HIGH) - { - USBD_GetString (USBD_SERIALNUMBER_HS_STRING, USBD_StrDesc, length); - } - else - { - USBD_GetString (USBD_SERIALNUMBER_FS_STRING, USBD_StrDesc, length); - } - return USBD_StrDesc; -} - -/** -* @brief USBD_USR_ConfigStrDescriptor -* return the configuration string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length) -{ - if(speed == USB_OTG_SPEED_HIGH) - { - USBD_GetString (USBD_CONFIGURATION_HS_STRING, USBD_StrDesc, length); - } - else - { - USBD_GetString (USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); - } - return USBD_StrDesc; -} - - -/** -* @brief USBD_USR_InterfaceStrDescriptor -* return the interface string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length) -{ - if(speed == 0) - { - USBD_GetString (USBD_INTERFACE_HS_STRING, USBD_StrDesc, length); - } - else - { - USBD_GetString (USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); - } - return USBD_StrDesc; -} - -/** - * @} - */ - - -/** - * @} - */ - - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/bsp/src/M4StickV2/usbd_desc.h b/bsp/src/M4StickV2/usbd_desc.h deleted file mode 100644 --- a/bsp/src/M4StickV2/usbd_desc.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_desc.h - * @author MCD Application Team - * @version V1.1.0 - * @date 19-March-2012 - * @brief header file for the usbd_desc.c file - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2012 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ - -#ifndef __USB_DESC_H -#define __USB_DESC_H - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_def.h" - -/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY - * @{ - */ - -/** @defgroup USB_DESC - * @brief general defines for the usb device library file - * @{ - */ - -/** @defgroup USB_DESC_Exported_Defines - * @{ - */ -#define USB_DEVICE_DESCRIPTOR_TYPE 0x01 -#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 -#define USB_STRING_DESCRIPTOR_TYPE 0x03 -#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 -#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 -#define USB_SIZ_DEVICE_DESC 18 -#define USB_SIZ_STRING_LANGID 4 - -/** - * @} - */ - - -/** @defgroup USBD_DESC_Exported_TypesDefinitions - * @{ - */ -/** - * @} - */ - - - -/** @defgroup USBD_DESC_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup USBD_DESC_Exported_Variables - * @{ - */ -extern uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC]; -extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ]; -extern uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC]; -extern uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]; -extern uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID]; -extern USBD_DEVICE USR_desc; -/** - * @} - */ - -/** @defgroup USBD_DESC_Exported_FunctionsPrototype - * @{ - */ - - -uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_ManufacturerStrDescriptor ( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_ProductStrDescriptor ( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length); - -#ifdef USB_SUPPORT_USER_STRING_DESC -uint8_t * USBD_USR_USRStringDesc (uint8_t speed, uint8_t idx , uint16_t *length); -#endif /* USB_SUPPORT_USER_STRING_DESC */ - -/** - * @} - */ - -#endif /* __USBD_DESC_H */ - -/** - * @} - */ - -/** -* @} -*/ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/src/M4StickV2/usbd_usr.c b/bsp/src/M4StickV2/usbd_usr.c deleted file mode 100644 --- a/bsp/src/M4StickV2/usbd_usr.c +++ /dev/null @@ -1,203 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_usr.c - * @author MCD Application Team - * @version V1.1.0 - * @date 19-March-2012 - * @brief This file includes the user application layer - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2012 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_usr.h" -#include "usbd_ioreq.h" -//#include "lcd_log.h" - -/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY -* @{ -*/ - -/** @defgroup USBD_USR -* @brief This file includes the user application layer -* @{ -*/ - -/** @defgroup USBD_USR_Private_TypesDefinitions -* @{ -*/ -/** -* @} -*/ - - -/** @defgroup USBD_USR_Private_Defines -* @{ -*/ -/** -* @} -*/ - - -/** @defgroup USBD_USR_Private_Macros -* @{ -*/ -/** -* @} -*/ - - -/** @defgroup USBD_USR_Private_Variables -* @{ -*/ - -USBD_Usr_cb_TypeDef USR_cb = -{ - USBD_USR_Init, - USBD_USR_DeviceReset, - USBD_USR_DeviceConfigured, - USBD_USR_DeviceSuspended, - USBD_USR_DeviceResumed, - - - USBD_USR_DeviceConnected, - USBD_USR_DeviceDisconnected, -}; - -/** -* @} -*/ - -/** @defgroup USBD_USR_Private_Constants -* @{ -*/ - -/** -* @} -*/ - - - -/** @defgroup USBD_USR_Private_FunctionPrototypes -* @{ -*/ -/** -* @} -*/ - - -/** @defgroup USBD_USR_Private_Functions -* @{ -*/ - -/** -* @brief USBD_USR_Init -* Displays the message on LCD for host lib initialization -* @param None -* @retval None -*/ -void USBD_USR_Init(void) -{ - /* Initialize LEDs */ - //STM_EVAL_LEDInit(LED1); - //STM_EVAL_LEDInit(LED2); - //STM_EVAL_LEDInit(LED3); - //STM_EVAL_LEDInit(LED4); - -} - -/** -* @brief USBD_USR_DeviceReset -* Displays the message on LCD on device Reset Event -* @param speed : device speed -* @retval None -*/ -void USBD_USR_DeviceReset(uint8_t speed ) -{ - -} - - -/** -* @brief USBD_USR_DeviceConfigured -* Displays the message on LCD on device configuration Event -* @param None -* @retval Staus -*/ -void USBD_USR_DeviceConfigured (void) -{ -} - -/** -* @brief USBD_USR_DeviceSuspended -* Displays the message on LCD on device suspend Event -* @param None -* @retval None -*/ -void USBD_USR_DeviceSuspended(void) -{ - - /* Users can do their application actions here for the USB-Reset */ -} - - -/** -* @brief USBD_USR_DeviceResumed -* Displays the message on LCD on device resume Event -* @param None -* @retval None -*/ -void USBD_USR_DeviceResumed(void) -{ - - /* Users can do their application actions here for the USB-Reset */ -} - - -/** -* @brief USBD_USR_DeviceConnected -* Displays the message on LCD on device connection Event -* @param None -* @retval Staus -*/ -void USBD_USR_DeviceConnected (void) -{ - -} - - -/** -* @brief USBD_USR_DeviceDisonnected -* Displays the message on LCD on device disconnection Event -* @param None -* @retval Staus -*/ -void USBD_USR_DeviceDisconnected (void) -{ - -} -/** -* @} -*/ - -/** -* @} -*/ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/src/OPLAYER/OPLAYER.pro b/bsp/src/OPLAYER/OPLAYER.pro deleted file mode 100644 --- a/bsp/src/OPLAYER/OPLAYER.pro +++ /dev/null @@ -1,28 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp -CONFIG += bsp gui audio fs - -BSP = OPLAYER - -UCMODEL=stm32f4 - -SOURCES += bsp.c \ - bsp_spi.c \ - bsp_lcd.c \ - bsp_sdcard.c \ - bsp_audio.c - -HEADERS += bsp.h \ - ../common/bsp_spi.h \ - ../common/bsp_i2c.h \ - ../common/bsp_gpio.h - -INCLUDEPATH += ../common/ - -LIBS+= -lgpio -luart -li2c -lspi - -BSPFILE = bsp.pri - - - diff --git a/bsp/src/OPLAYER/bsp.c b/bsp/src/OPLAYER/bsp.c deleted file mode 100644 --- a/bsp/src/OPLAYER/bsp.c +++ /dev/null @@ -1,204 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2013, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "bsp_gpio.h" -#include "bsp_i2c.h" -#include "bsp_i2c.h" - -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - - - -LCD_IF_t lcdIF0={ - .init = &bsp_FSMC_init, - .writereg = &bsp_lcd0_write_reg, - .readreg = &bsp_lcd0_read_reg, - .writeGRAM = &bsp_lcd0_writeGRAM, - .readGRAM = &bsp_lcd0_readGRAM -}; - -LCD_t lcd0={ - .interface = &lcdIF0, - .init = &ili9328init, - .paint = &ili9328paint, - .paintText = &ili9328paintText, - .paintFilRect = &ili9328paintFilRect, - .getPix = &ili9328getPix, - .refreshenable = &ili9328refreshenable, - .width= 240, - .height = 320 -}; - -terminal_t terminal0; - - - -float VREF0 =(float)3.3; -volatile vs10XXDev audioCodec0; - -ADS7843_t TC0; - -sdcardDev sdcard2; -blkdevice sdcard2blkdev; -dikpartition sdcard2Part1; -FAT32fs sdcard2FAT32part1; -dikpartition sdcard2Part2; -FAT32fs sdcard2FAT32part2; -dikpartition sdcard2Part3; -FAT32fs sdcard2FAT32part3; -dikpartition sdcard2Part4; -FAT32fs sdcard2FAT32part4; - -int bsp_init() -{ - int i=0; - for(i=0;i<__MAX_OPENED_FILES__;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - bsp_iic_init(); - bsp_FSMC_init(); - bsp_GTerm_init(); - bsp_spi_init(); - bsp_SD_init(); - bsp_Audio_init(); - bsp_TC_init(); - printf("\r=====================\n\r"); - printf( "=====================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf( "=====================\n\r"); -#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - printf( "BIG ENDIAN MACHINE\n\r"); -#else - printf( "LITLE ENDIAN MACHINE\n\r"); -#endif - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t GPIO_Out_init_List[]={LED1,LED2,LCD_RESET,LCD_BACKL,VS1053xCS,VS1053xDCS,\ - VS1053xRESET,SDCARD2CS,LCD_RS,LCD_CS,TC_CS}; - - gpio_t GPIO_In_init_List[]={VS1053DREQ,SDCARD2CD,BP3,TC_BUSY}; - - bsp_gpio_set_outputs(GPIO_Out_init_List,11); - bsp_gpio_set_inputs(GPIO_In_init_List,4); - - gpioclr(VS1053xRESET); - gpioset(VS1053xCS); - gpioset(VS1053xDCS); - gpioset(SDCARD2CS); - gpioclr(LCD_RESET); - gpioclr(LCD_BACKL); -} - -void bsp_uart_init() -{ - -} - - - - - -int bsp_TC_init() -{ - ads7843init(&TC0,TC_SPI,tcsetncs,tcbusy); -} - - - - -void bsp_iic_init() -{ - // i2copenandconfig(i2c2,0,10000,PF0,PF1); -} - - - - -void tcsetncs(char val) -{ - if(val) - gpioset(TC_CS); - else - gpioclr(TC_CS); -} - -int tcbusy() -{ - return gpiogetval(TC_BUSY); -} - - - - - -void bsp_GTerm_init() -{ - if(__opnfiles__[1]==NULL) - { - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); - terminal_settextColor(&terminal0,0); - __opnfiles__[1] = fd1; - } - else - { - - } -} - - - - - - - - - - - - - - - - - diff --git a/bsp/src/OPLAYER/bsp.h b/bsp/src/OPLAYER/bsp.h deleted file mode 100644 --- a/bsp/src/OPLAYER/bsp.h +++ /dev/null @@ -1,151 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) -#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) - - -#define __MAX_OPENED_FILES__ 4 -#define __FS_ROOT_SIZE__ 4 - - -#define LED1 PC15 -#define LED2 PC14 - -#define BP3 PA0 - -#define LCD_RESET PD10 -#define LCD_BACKL PE11 -#define LCD_RS PE4 -#define LCD_CS PD7 - -#define TC_SPI spi2 -#define TC_PEN PC4 -#define TC_BUSY PC5 -#define TC_CS PB12 -#define TC_CLK PB13 -#define TC_DOUT PB14 -#define TC_DIN PB15 - -#define VS1053SPI spi1 -#define VS1053xCS PA3 -#define VS1053xRESET PA2 -#define VS1053xDCS PA4 -#define VS1053DREQ PA1 -#define VS1053MISO PA6 -#define VS1053MOSI PA7 -#define VS1053SCK PA5 - - - -#define SDCARD2SPI spi3 -#define SDCARD2CS PB8 -#define SDCARD2CD PB9 -#define SDCARD2MISO PB4 -#define SDCARD2MOSI PB5 -#define SDCARD2SCK PB3 - -extern float VREF0; - -extern uint32_t currentCpuFreq; -extern LCD_t lcd0; -extern ADS7843_t TC0; - -extern volatile vs10XXDev audioCodec0; - -extern sdcardDev sdcard2; -extern blkdevice sdcard2blkdev; -extern dikpartition sdcard2Part1; -extern FAT32fs sdcard2FAT32part1; -extern dikpartition sdcard2Part2; -extern FAT32fs sdcard2FAT32part2; -extern dikpartition sdcard2Part3; -extern FAT32fs sdcard2FAT32part3; -extern dikpartition sdcard2Part4; -extern FAT32fs sdcard2FAT32part4; - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); -extern void bsp_Audio_init(); -extern void bsp_GTerm_init(); -extern int bsp_FSMC_init(); -extern int bsp_TC_init(); -extern void tcsetncs(char val); -extern int tcbusy(); -/* VS1053 */ -extern void vs1052setXCS(char val); -extern void vs1052setXDCS(char val); -extern void vs1052setRST(char val); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); -uint32_t bsp_lcd0_read_reg(uint32_t reg); -void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); -void bsp_lcd0_readGRAM(void *buffer, uint32_t count); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/OPLAYER/bsp.pri b/bsp/src/OPLAYER/bsp.pri deleted file mode 100644 --- a/bsp/src/OPLAYER/bsp.pri +++ /dev/null @@ -1,4 +0,0 @@ -CPU=stm32f4xxxG -DEFINES+=BSP=\\\"OPLAYER\\\" - -UCMODEL=stm32f4 diff --git a/bsp/src/OPLAYER/bsp_audio.c b/bsp/src/OPLAYER/bsp_audio.c deleted file mode 100644 --- a/bsp/src/OPLAYER/bsp_audio.c +++ /dev/null @@ -1,94 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2013, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void bsp_Audio_init() -{ - vs10XXopen(&audioCodec0,VS1053SPI,vs1052setXCS,vs1052setRST,vs1052setXDCS,vs10XXDREQ); - if(audioCodec0.VERSION!=UNKNOWN) - { - printf("detected Audio codec "); - switch (audioCodec0.VERSION) { - case VS1001: - printf("VS1001\n"); - break; - case VS1011: - printf("VS1011\n"); - break; - case VS1002: - printf("VS1002\n"); - break; - case VS1003: - printf("VS1003\n"); - break; - case VS1053: - printf("VS1053\n"); - break; - case VS1033: - printf("VS1033\n"); - break; - case VS1103: - printf("VS1103\n"); - break; - default: - printf("Unknown device\n"); - break; - } - } -} - - - -void vs1052setXCS(char val) -{ - gpiosetval(VS1053xCS,(int)val); -} - -void vs1052setXDCS(char val) -{ - //gpiosetval(LED1,(int)val); - gpiosetval(VS1053xDCS,(int)val); -} - -void vs1052setRST(char val) -{ - if(val) - gpioset(VS1053xRESET); - else - gpioclr(VS1053xRESET); -} - - -int vs10XXDREQ() -{ - return gpiogetval(VS1053DREQ); -} diff --git a/bsp/src/OPLAYER/bsp_lcd.c b/bsp/src/OPLAYER/bsp_lcd.c deleted file mode 100644 --- a/bsp/src/OPLAYER/bsp_lcd.c +++ /dev/null @@ -1,266 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2013, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define clr_RS gpioclr(LCD_RS) -#define set_RS gpioset(LCD_RS) - -#define clr_CS gpioclr(LCD_CS) -#define set_CS gpioset(LCD_CS) - -volatile int8_t* lcd0_CMD=(volatile int8_t*)0x60000000; -volatile int16_t* lcd0_CMD16=(volatile int16_t*)0x60000000; -volatile int8_t* lcd0_DATA=(volatile int8_t*)0x61FFFFF0; -volatile int16_t* lcd0_DATA16=(volatile int16_t*)0x61FFFFF0; - -/* -D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 -D5 PE8 D6 PE9 D7 PE10 -A20 PE4 = RS FSMC_NE1 PD7 CS FSMC_NWE PD5 W/S -FSMC_NOE PD4 RD -*/ - -int bsp_FSMC_init() -{ - - gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10\ - ,PD4,PD5}; -// gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10\ -// ,PD4,PD5,PD7,PE4}; - for(int i=0;i<10;i++) - { - gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); - LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; - gpiosetconfig(&LCD_DBx); - GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); - } - - FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; - FSMC_NORSRAMTimingInitTypeDef p; - - /* Enable FSMC clock */ - RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); - - /*-- FSMC Configuration ------------------------------------------------------*/ - /*----------------------- SRAM Bank 3 ----------------------------------------*/ - /* FSMC_Bank1_NORSRAM4 configuration */ - p.FSMC_AddressSetupTime = 1;//3 - p.FSMC_AddressHoldTime = 1;//3 - //ili9328 -> data setup time > 10ns - p.FSMC_DataSetupTime = 6; - p.FSMC_CLKDivision = 3; - if(getCpuFreq()>=100*1000*1000) - { - p.FSMC_CLKDivision = 3; - p.FSMC_DataSetupTime = 6;// 11; - } - p.FSMC_BusTurnAroundDuration = 0; - p.FSMC_DataLatency = 3; - //ili9328 -> data hold time > 15ns - if(getCpuFreq()>66*1000*1000) - p.FSMC_DataLatency = 3; - p.FSMC_AccessMode = FSMC_AccessMode_D; - - - FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; - FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; - FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR; - FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; - FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; - FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; - FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; - FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; //Dis - FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; - FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; - FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; - - FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); - - FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); - gpioset(LCD_RESET); - gpioclr(LCD_RESET); - delay_100us(500); - gpioset(LCD_RESET); - delay_100us(500); - lcd0.init(&lcd0); - gpioset(LCD_BACKL); - return 1; -} - - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) -{ - uint8_t* pt8 = (uint8_t*)(void*)(®); -#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - *lcd0_CMD=pt8[3]; - *lcd0_CMD=pt8[2]; - pt8 = (uint8_t*)(void*)&data; - *lcd0_DATA=pt8[3]; - *lcd0_DATA=pt8[2]; -#else - clr_CS; - clr_RS; - *lcd0_CMD=pt8[1]; - *lcd0_CMD=pt8[0]; - set_RS; - pt8 = (uint8_t*)(void*)&data; - *lcd0_DATA=pt8[1]; - *lcd0_DATA=pt8[0]; - set_CS; -#endif - -} - -uint32_t bsp_lcd0_read_reg(uint32_t reg) -{ - uint8_t* pt8 = (uint8_t*)(void*)(®); - uint32_t DATA=0; - -#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - *lcd0_CMD=pt8[3]; - *lcd0_CMD=pt8[2]; - pt8 = (uint8_t*)(void*)&DATA; - pt8[3]=*lcd0_DATA; - pt8[2]=*lcd0_DATA; -#else - clr_CS; - clr_RS; - *lcd0_CMD=pt8[1]; - *lcd0_CMD=pt8[0]; - set_RS; - pt8 = (uint8_t*)(void*)&DATA; - pt8[1]=*lcd0_DATA; - pt8[0]=*lcd0_DATA; - set_CS; -#endif - - return DATA; -} - -void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) -{ - uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; - uint8_t* pt8 = (uint8_t*)(void*)(®); -#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - *lcd0_CMD=pt8[3]; - *lcd0_CMD=pt8[2]; - pt8 = (uint8_t*)(void*)buffer; - for(int i=0;i<(int)count;i++) - { - *lcd0_DATA=pt8[(2*i) +1]; - *lcd0_DATA=pt8[2*i]; - } -#else - clr_CS; - clr_RS; - *lcd0_CMD=pt8[1]; - *lcd0_CMD=pt8[0]; - set_RS; - pt8 = (uint8_t*)(void*)buffer; - for(int i=0;i<(int)count;i++) - { - - *lcd0_DATA=pt8[(2*i) +1]; - *lcd0_DATA=pt8[2*i]; - } - set_CS; -#endif -} - - -void bsp_lcd0_readGRAM(void* buffer,uint32_t count) -{ - //uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; - volatile uint8_t* pt8;// = (uint8_t*)(void*)® - /* #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - *lcd0_CMD=pt8[3]; - *lcd0_CMD=pt8[2]; - pt8 = (uint8_t*)(void*)buffer; - for(int i=0;i<(int)count;i++) - { - pt8[(2*i) +1]=*lcd0_DATA; - pt8[2*i]=*lcd0_DATA; - } -#else - *lcd0_CMD=(uint8_t)0; - *lcd0_CMD=(uint8_t)0; - *lcd0_CMD=(uint8_t)0; - *lcd0_CMD=(uint8_t)0; - *lcd0_CMD=pt8[1]; - *lcd0_CMD=pt8[0]; - pt8 = (uint8_t*)buffer;*/ - /* - * x dummy reads Cf ili9328 datasheet p79! - */ - /* pt8[0]=*lcd0_DATA; - pt8[1]=*lcd0_DATA; - - for(int i=0;i<(int)count;i++) - { - pt8[(2*i) +1]=*lcd0_DATA; - pt8[2*i]=*lcd0_DATA; - pt8[(2*i) +1]=*lcd0_DATA; - pt8[2*i]=*lcd0_DATA; - } -#endif*/ - //clr_CS; - //clr_RS; - //*lcd0_CMD=(int8_t)0; - //*lcd0_CMD=(int8_t)0x22; -// *lcd0_CMD=(int8_t)0x00; - //set_RS; - pt8 = (uint8_t*)buffer; - //pt8[1]=*lcd0_DATA; - //pt8[0]=*lcd0_DATA; - pt8[0]=0xFF; - pt8[1]=0xFF; -/* for(int i=0;i<(int)count;i++) - { - pt8[(2*i)+1]= *lcd0_DATA; - pt8[2*i]= *lcd0_DATA; - }*/ - set_CS; -} - - - - - - - - diff --git a/bsp/src/OPLAYER/bsp_sdcard.c b/bsp/src/OPLAYER/bsp_sdcard.c deleted file mode 100644 --- a/bsp/src/OPLAYER/bsp_sdcard.c +++ /dev/null @@ -1,116 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2013, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -void bsp_SD_init() -{ - if(bspsdcardpresent()) - { - sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed); - sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); - if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT) - { - if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr) - { - if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1)) - printf("Can't open fat32 partition 1\n"); - } - else - { - printf("Can't open or read MBR\n"); - } - if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr) - { - if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2)) - printf("Can't open fat32 partition 2\n"); - } - else - { - printf("Can't open or read MBR\n"); - } - if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr) - { - if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3)) - printf("Can't open fat32 partition 3\n"); - } - else - { - printf("Can't open or read MBR\n"); - } - if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr) - { - if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4)) - printf("Can't open fat32 partition 4\n"); - } - else - { - printf("Can't open or read MBR\n"); - } - } - else - { - printf("Can't initialize SDCARD\n"); - } - } -} - - - - - - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return gpiogetval(SDCARD2CD); -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - // gpiosetval(LED1,(int)YESNO); - if(YESNO) - gpioclr(SDCARD2CS); - else - gpioset(SDCARD2CS); -} - diff --git a/bsp/src/OPLAYER/bsp_spi.c b/bsp/src/OPLAYER/bsp_spi.c deleted file mode 100644 --- a/bsp/src/OPLAYER/bsp_spi.c +++ /dev/null @@ -1,70 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2013, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) -#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) - - -void bsp_spi_init() -{ - gpio_t VSSPI_DBxList[]={VS1053SCK,VS1053MOSI,VS1053MISO}; - for(int i=0;i<3;i++) - { - gpio_t SPI_DBx = gpioopen(VSSPI_DBxList[i]); - SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; - gpiosetconfig(&SPI_DBx); - GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI1); - } - spiopenandconfig(VS1053SPI,spi8bits|spimaster|spimsbfirst,2*1000*1000,VS1053MOSI,VS1053MISO,VS1053SCK,-1); - - gpio_t SDSPI_DBxList[]={SDCARD2SCK,SDCARD2MOSI,SDCARD2MISO}; - for(int i=0;i<3;i++) - { - gpio_t SPI_DBx = gpioopen(SDSPI_DBxList[i]); - SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; - gpiosetconfig(&SPI_DBx); - GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI3); - } - spiopenandconfig(SDCARD2SPI,spi8bits|spimaster|spimsbfirst,400*1000,SDCARD2MOSI,SDCARD2MISO,SDCARD2SCK,-1); - - gpio_t TCSPI_DBxList[]={TC_CLK,TC_DIN,TC_DOUT}; - for(int i=0;i<3;i++) - { - gpio_t SPI_DBx = gpioopen(TCSPI_DBxList[i]); - SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; - gpiosetconfig(&SPI_DBx); - GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI2); - } - spiopenandconfig(TC_SPI,spi8bits|spimaster|spimsbfirst,500*1000,TC_DIN,TC_DOUT,TC_CLK,-1); - -} diff --git a/bsp/src/SIMULATOR/SIMULATOR.pro b/bsp/src/SIMULATOR/SIMULATOR.pro deleted file mode 100644 --- a/bsp/src/SIMULATOR/SIMULATOR.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp -CONFIG += bsp gui fs - - -BSP = SIMULATOR - -UCMODEL=simulator - -SOURCES += bsp.c - -HEADERS += bsp.h - -LIBS+= -lgpio -luart -li2c -lspi -BSPFILE = bsp.pri - - - diff --git a/bsp/src/SIMULATOR/bsp.c b/bsp/src/SIMULATOR/bsp.c deleted file mode 100644 --- a/bsp/src/SIMULATOR/bsp.c +++ /dev/null @@ -1,332 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include - - -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - - -LCD_IF_t lcdIF0={ - .init = &SDLCD_init, - .writereg = &SDLCD_writereg, - .readreg = &SDLCD_readreg, - .writeGRAM = &SDLCD_writeGRAM_16bpp, - .readGRAM = &SDLCD_readGRAM_16bpp -}; - -LCD_t lcd0={ - .interface = &lcdIF0, - .init = &ili9328init, - .paint = &ili9328paint, - .paintText = &ili9328paintText, - .paintFilRect = &ili9328paintFilRect, - .getPix = &ili9328getPix, - .refreshenable = &ili9328refreshenable, - .width= 240, - .height = 320 -}; - -terminal_t terminal0; - -volatile int8_t* lcd0_CMD=(volatile int8_t*) 0x60000000; -volatile int8_t* lcd0_DATA=(volatile int8_t*)(0x61FFFFF0); - -float VREF0 =(float)3.3; -volatile vs10XXDev audioCodec0; - -sdcardDev sdcard2; -blkdevice sdcard2blkdev; -dikpartition sdcard2Part1; -FAT32fs sdcard2FAT32part1; -dikpartition sdcard2Part2; -FAT32fs sdcard2FAT32part2; -dikpartition sdcard2Part3; -FAT32fs sdcard2FAT32part3; -dikpartition sdcard2Part4; -FAT32fs sdcard2FAT32part4; - -int bsp_init() -{ - int i=0; - for(i=0;i<__MAX_OPENED_FILES__;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - bsp_iic_init(); - bsp_FSMC_init(); - bsp_GTerm_init(); - bsp_spi_init(); - bsp_SD_init(); - bsp_Audio_init(); - printf("\r=====================\n\r"); - printf( "=====================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf( "=====================\n\r"); - return 1; -} - -void bsp_GPIO_init() -{ - -} - -void bsp_uart_init() -{ - -} - -/* -D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 -D5 PE8 D6 PE9 D7 PE10 -A20 PE4 = RS FSMC_NE1 PD7 CS FSMC_NWE PD5 W/S -FSMC_NOE PD4 RD -*/ - -int bsp_FSMC_init() -{ - - return 1; -} - -void bsp_spi_init() -{ - -} - - -void bsp_iic_init() -{ - -} - - -void bsp_Audio_init() -{ - -} - -void bsp_SD_init() -{ - sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2, bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); - if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT) - { - if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr) - { - if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1)) - printf("Can't open fat32 partition 1\n"); - } - else - { - printf("Can't open or read MBR\n"); - } - delay_100us(1000); - if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr) - { - if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2)) - printf("Can't open fat32 partition 2\n"); - } - else - { - printf("Can't open or read MBR\n"); - } - delay_100us(1000); - if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr) - { - if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3)) - printf("Can't open fat32 partition 3\n"); - } - else - { - printf("Can't open or read MBR\n"); - } - delay_100us(1000); - if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr) - { - if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4)) - printf("Can't open fat32 partition 4\n"); - } - else - { - printf("Can't open or read MBR\n"); - } - } - else - { - printf("Can't initialize SDCARD\n"); - } - - delay_100us(2000); -} - -void vs1052setXCS(char val) -{ -} - -void vs1052setXDCS(char val) -{ -} - -void vs1052setRST(char val) -{ -} - -int vs10XXDREQ() -{ - return 1; -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return 1; -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) -{ - -} - -uint32_t bsp_lcd0_read_reg(uint32_t reg) -{ - return 0; -} - -void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) -{ - -} - -void bsp_lcd0_readGRAM(void* buffer,uint32_t count) -{ - -} - -void bsp_GTerm_init() -{ - SDLCD_mkscreen(240,320,16,LCDILI9328); - - if(__opnfiles__[1]==NULL) - { - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - terminal_init(&terminal0 ,&lcd0,&ComicSansMS_18,fd1); - lcd0.paintFilRect(&lcd0,0,0,240,320,0,0,0x0f0f); - __opnfiles__[1] = fd1; - } - else - { - - } -} - - - - - - - -void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel) -{ - int bpp = surface->format->BytesPerPixel; - /* Here p is the address to the pixel we want to set */ - Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; - switch(bpp) { - case 1: - *p = pixel; - break; - case 2: - *(Uint16 *)p = pixel; - break; - case 3: - if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { - p[0] = (pixel >> 16) & 0xff; - p[1] = (pixel >> 8) & 0xff; - p[2] = pixel & 0xff; - } else { - p[0] = pixel & 0xff; - p[1] = (pixel >> 8) & 0xff; - p[2] = (pixel >> 16) & 0xff; - } - break; - case 4: - *(Uint32 *)p = pixel; - break; - } -} - -Uint32 getpixel(SDL_Surface *surface, int x, int y) -{ - int bpp = surface->format->BytesPerPixel; - /* Here p is the address to the pixel we want to retrieve */ - Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; - switch(bpp) { - case 1: - return *p; - case 2: - return *(Uint16 *)p; - case 3: - if(SDL_BYTEORDER == SDL_BIG_ENDIAN) - return p[0] << 16 | p[1] << 8 | p[2]; - else - return p[0] | p[1] << 8 | p[2] << 16; - case 4: - return *(Uint32 *)p; - default: - return 0; - } - /* shouldn’t happen, but avoids warnings */ -} - - - - - - - - - - diff --git a/bsp/src/SIMULATOR/bsp.h b/bsp/src/SIMULATOR/bsp.h deleted file mode 100644 --- a/bsp/src/SIMULATOR/bsp.h +++ /dev/null @@ -1,139 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define __MAX_OPENED_FILES__ 4 -#define __FS_ROOT_SIZE__ 4 - - -#define LED1 PC15 -#define LED2 PC14 - -#define BP3 PA0 - -#define LCD_RESET PD10 -#define LCD_BACKL PE11 - -#define VS1053SPI spi1 -#define VS1053xCS PA3 -#define VS1053xRESET PA2 -#define VS1053xDCS PA4 -#define VS1053DREQ PA1 -#define VS1053MISO PA6 -#define VS1053MOSI PA7 -#define VS1053SCK PA5 - - - -#define SDCARD2SPI spi3 -#define SDCARD2CS PB8 -#define SDCARD2CD PB9 -#define SDCARD2MISO PB4 -#define SDCARD2MOSI PB5 -#define SDCARD2SCK PB3 - -extern float VREF0; - -extern uint32_t currentCpuFreq; -extern LCD_t lcd0; - -extern volatile vs10XXDev audioCodec0; - -extern sdcardDev sdcard2; -extern blkdevice sdcard2blkdev; -extern dikpartition sdcard2Part1; -extern FAT32fs sdcard2FAT32part1; -extern dikpartition sdcard2Part2; -extern FAT32fs sdcard2FAT32part2; -extern dikpartition sdcard2Part3; -extern FAT32fs sdcard2FAT32part3; -extern dikpartition sdcard2Part4; -extern FAT32fs sdcard2FAT32part4; - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); -extern void bsp_Audio_init(); -extern void bsp_GTerm_init(); -extern int bsp_FSMC_init(); - -/* VS1053 */ -extern void vs1052setXCS(char val); -extern void vs1052setXDCS(char val); -extern void vs1052setRST(char val); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); -uint32_t bsp_lcd0_read_reg(uint32_t reg); -void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); -void bsp_lcd0_readGRAM(void *buffer, uint32_t count); - - -extern void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel); -extern Uint32 getpixel(SDL_Surface *surface, int x, int y); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/SIMULATOR/bsp.pri b/bsp/src/SIMULATOR/bsp.pri deleted file mode 100644 --- a/bsp/src/SIMULATOR/bsp.pri +++ /dev/null @@ -1,6 +0,0 @@ -CPU=simultor -DEFINES+=BSP=\\\"SIMULATOR\\\" - -UCMODEL=simulator - -LIBS+=-lSDLCD diff --git a/bsp/src/SOLAR_LFR_PSU/SOLAR_LFR_PSU.pro b/bsp/src/SOLAR_LFR_PSU/SOLAR_LFR_PSU.pro deleted file mode 100644 --- a/bsp/src/SOLAR_LFR_PSU/SOLAR_LFR_PSU.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp -CONFIG += bsp - -BSP=SOLAR_LFR_PSU - -UCMODEL=stm32f4 - -SOURCES += bsp.c - -HEADERS += bsp.h - -LIBS+= -lgpio -luart -li2c -lspi - -BSPFILE = bsp.pri - - - diff --git a/bsp/src/SOLAR_LFR_PSU/bsp.c b/bsp/src/SOLAR_LFR_PSU/bsp.c deleted file mode 100644 --- a/bsp/src/SOLAR_LFR_PSU/bsp.c +++ /dev/null @@ -1,140 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include - -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - -float VREF0 =(float)3.3; - -int bsp_init() -{ - int i=0; - for(i=0;i<32;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - bsp_iic_init(); - printf("\r================================================================\n\r"); - printf("================================================================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf("================================================================\n\r"); - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 - gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); - gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); - gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); - gpio_t dacRst=gpioopen(PD4); - gpiosetspeed(&gpio1,gpiohighspeed); - gpiosetspeed(&gpio2,gpiohighspeed); - gpiosetspeed(&gpio3,gpiohighspeed); - gpiosetspeed(&gpio4,gpiohighspeed); - gpiosetspeed(&dacRst,gpiohighspeed); - gpiosetdir(&gpio1,gpiooutdir); - gpiosetdir(&gpio3,gpiooutdir); - gpiosetdir(&gpio2,gpiooutdir); - gpiosetdir(&gpio4,gpiooutdir); - gpiosetdir(&dacRst,gpiooutdir); - gpioset(dacRst); -} - -void bsp_uart_init() -{ - if(__opnfiles__[1]==NULL) - { - //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); - uartmkstreamdev(uart,fd1); - __opnfiles__[1] = fd1; - } - else - { - uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); - } -} - -void bsp_spi_init() -{ - -} - - -void bsp_iic_init() -{ - i2copenandconfig(i2c1,0,400000,PB9,PB6); - i2copenandconfig(i2c3,0,400000,PC9,PA8); -} - -void bsp_SD_init() -{ - -} - -void vs10XXclearXCS(){} -void vs10XXsetXCS(){} -int vs10XXDREQ() -{ - return 1; -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return 0; -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - - - - - diff --git a/bsp/src/SOLAR_LFR_PSU/bsp.h b/bsp/src/SOLAR_LFR_PSU/bsp.h deleted file mode 100644 --- a/bsp/src/SOLAR_LFR_PSU/bsp.h +++ /dev/null @@ -1,87 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -#include -#include - -#define __MAX_OPENED_FILES__ 32 -#define __FS_ROOT_SIZE__ 32 -/* -#ifndef PD8 - #define PD8 -#endif -#ifndef PD9 - #define PD9 -#endif -*/ - -#define LED1 PD12 -#define LED2 PD13 -#define LED3 PD14 -#define LED4 PD15 - -extern float VREF0; - -extern uint32_t currentCpuFreq; - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); - -/* VS1053 */ -extern void clearXCS(); -extern void setXCS(); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/SOLAR_LFR_PSU/bsp.pri b/bsp/src/SOLAR_LFR_PSU/bsp.pri deleted file mode 100644 --- a/bsp/src/SOLAR_LFR_PSU/bsp.pri +++ /dev/null @@ -1,3 +0,0 @@ -CPU=stm32f4xxxG -DEFINES+=BSP=\\\"SOLAR_LFR_PSU\\\" -UCMODEL=stm32f4 diff --git a/bsp/src/STM32-E407/STM32-E407.pro b/bsp/src/STM32-E407/STM32-E407.pro deleted file mode 100644 --- a/bsp/src/STM32-E407/STM32-E407.pro +++ /dev/null @@ -1,26 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp -CONFIG += bsp - -BSP = STM32-E407 - -UCMODEL=stm32f4 - -SOURCES += bsp.c \ - bsp_spi.c \ - bsp_sdcard.c - -HEADERS += bsp.h \ - ../common/bsp_spi.h \ - ../common/bsp_i2c.h \ - ../common/bsp_gpio.h - -INCLUDEPATH += ../common/ - -LIBS+= -lgpio -luart -li2c -lspi - -BSPFILE = bsp.pri - - - diff --git a/bsp/src/STM32-E407/bsp.c b/bsp/src/STM32-E407/bsp.c deleted file mode 100644 --- a/bsp/src/STM32-E407/bsp.c +++ /dev/null @@ -1,139 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2013, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "bsp_gpio.h" -#include "bsp_i2c.h" -#include "bsp_i2c.h" - -uint32_t OSC0 =12000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - - -float VREF0 =(float)3.3; - -sdcardDev sdcard2; -blkdevice sdcard2blkdev; -dikpartition sdcard2Part1; -FAT32fs sdcard2FAT32part1; -dikpartition sdcard2Part2; -FAT32fs sdcard2FAT32part2; -dikpartition sdcard2Part3; -FAT32fs sdcard2FAT32part3; -dikpartition sdcard2Part4; -FAT32fs sdcard2FAT32part4; - -int bsp_init() -{ - int i=0; - for(i=0;i<__MAX_OPENED_FILES__;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - bsp_iic_init(); - bsp_spi_init(); - bsp_SD_init(); - printf("\r=====================\n\r"); - printf( "=====================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf( "=====================\n\r"); -#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - printf( "BIG ENDIAN MACHINE\n\r"); -#else - printf( "LITLE ENDIAN MACHINE\n\r"); -#endif - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t GPIO_Out_init_List[]={LED1}; - - gpio_t GPIO_In_init_List[]={BP1}; - - bsp_gpio_set_outputs(GPIO_Out_init_List,1); - bsp_gpio_set_inputs(GPIO_In_init_List,1); - -} - -void bsp_uart_init() -{ - if(__opnfiles__[1]==NULL) - { - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - uart_t uart = uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,115200,PC6,PC7,-1,-1); - uartmkstreamdev(uart,fd1); - __opnfiles__[1] = fd1; - } - else - { - uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,115200,PC6,PC7,-1,-1); - } -} - - - - -void bsp_iic_init() -{ - // i2copenandconfig(i2c2,0,10000,PF0,PF1); -} - - - - -void bsp_GTerm_init() -{ - -} - - - - - - - - - - - - - - - - - diff --git a/bsp/src/STM32-E407/bsp.h b/bsp/src/STM32-E407/bsp.h deleted file mode 100644 --- a/bsp/src/STM32-E407/bsp.h +++ /dev/null @@ -1,98 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define __MAX_OPENED_FILES__ 4 -#define __FS_ROOT_SIZE__ 4 - - -#define LED1 PC13 -#define LED2 PC13 - -#define BP1 PA0 - - -extern float VREF0; - -extern uint32_t currentCpuFreq; - - -extern sdcardDev sdcard2; -extern blkdevice sdcard2blkdev; -extern dikpartition sdcard2Part1; -extern FAT32fs sdcard2FAT32part1; -extern dikpartition sdcard2Part2; -extern FAT32fs sdcard2FAT32part2; -extern dikpartition sdcard2Part3; -extern FAT32fs sdcard2FAT32part3; -extern dikpartition sdcard2Part4; -extern FAT32fs sdcard2FAT32part4; - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/STM32-E407/bsp.pri b/bsp/src/STM32-E407/bsp.pri deleted file mode 100644 --- a/bsp/src/STM32-E407/bsp.pri +++ /dev/null @@ -1,4 +0,0 @@ -CPU=stm32f4xxxG -DEFINES+=BSP=\\\"STM32-E407\\\" - -UCMODEL=stm32f4 diff --git a/bsp/src/STM32-E407/bsp_sdcard.c b/bsp/src/STM32-E407/bsp_sdcard.c deleted file mode 100644 --- a/bsp/src/STM32-E407/bsp_sdcard.c +++ /dev/null @@ -1,60 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2013, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -void bsp_SD_init() -{ - -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - diff --git a/bsp/src/STM32-E407/bsp_spi.c b/bsp/src/STM32-E407/bsp_spi.c deleted file mode 100644 --- a/bsp/src/STM32-E407/bsp_spi.c +++ /dev/null @@ -1,38 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2013, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void bsp_spi_init() -{ - - -} diff --git a/bsp/src/STM32F429Discovery/STM32F429Discovery.pro b/bsp/src/STM32F429Discovery/STM32F429Discovery.pro deleted file mode 100644 --- a/bsp/src/STM32F429Discovery/STM32F429Discovery.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp -CONFIG += bsp - -BSP=STM32F429Discovery - -UCMODEL=stm32f4 - -SOURCES += bsp.c - -HEADERS += bsp.h - -LIBS+= -lgpio -luart -li2c -lspi - -BSPFILE = bsp.pri - - - diff --git a/bsp/src/STM32F429Discovery/bsp.c b/bsp/src/STM32F429Discovery/bsp.c deleted file mode 100644 --- a/bsp/src/STM32F429Discovery/bsp.c +++ /dev/null @@ -1,131 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - -float VREF0 =(float)3.3; - -int bsp_init() -{ - int i=0; - for(i=0;i<32;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - printf("\r================================================================\n\r"); - printf("================================================================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf("================================================================\n\r"); - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t gpio1 = gpioopen(LED1); - gpio_t gpio2 = gpioopen(LED2); - gpio_t gpio3 = gpioopen(BP0); - gpiosetspeed(&gpio1,gpiohighspeed); - gpiosetspeed(&gpio2,gpiohighspeed); - gpiosetspeed(&gpio3,gpiohighspeed); - gpiosetdir(&gpio1,gpiooutdir); - gpiosetdir(&gpio2,gpiooutdir); - gpiosetdir(&gpio3,gpioindir); -} - -void bsp_uart_init() -{ - if(__opnfiles__[1]==NULL) - { - //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); - 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; //stdo - __opnfiles__[0] = fd1; //stdi - } - else - { - uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); - } -} - -void bsp_spi_init() -{ - -} - - -void bsp_iic_init() -{ - -} - -void bsp_SD_init() -{ - -} - - -void vs10XXclearXCS(){} -void vs10XXsetXCS(){} -int vs10XXDREQ() -{ - return 1; -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return 0; -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - - - - - diff --git a/bsp/src/STM32F429Discovery/bsp.h b/bsp/src/STM32F429Discovery/bsp.h deleted file mode 100644 --- a/bsp/src/STM32F429Discovery/bsp.h +++ /dev/null @@ -1,80 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include - -#define __MAX_OPENED_FILES__ 32 -#define __FS_ROOT_SIZE__ 32 - -#define LED1 PG13 -#define LED2 PG14 - -#define BP0 PA0 - -extern float VREF0; - -extern uint32_t OSC0; -extern uint32_t currentCpuFreq; - - - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); - -/* VS1053 */ -extern void clearXCS(); -extern void setXCS(); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/STM32F429Discovery/bsp.pri b/bsp/src/STM32F429Discovery/bsp.pri deleted file mode 100644 --- a/bsp/src/STM32F429Discovery/bsp.pri +++ /dev/null @@ -1,3 +0,0 @@ -CPU=stm32f42x -DEFINES+=BSP=\\\"STM32F429Discovery\\\" -UCMODEL=stm32f4 diff --git a/bsp/src/STM32F4Discovery-EXT/STM32F4Discovery-EXT.pro b/bsp/src/STM32F4Discovery-EXT/STM32F4Discovery-EXT.pro deleted file mode 100644 --- a/bsp/src/STM32F4Discovery-EXT/STM32F4Discovery-EXT.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp -CONFIG += bsp gui - -BSP=STM32F4Discovery-EXT - -UCMODEL=stm32f4 - -SOURCES += bsp.c - -HEADERS += bsp.h -LIBS+= -lgpio -luart -li2c -lspi - -BSPFILE = bsp.pri - - - diff --git a/bsp/src/STM32F4Discovery-EXT/bsp.c b/bsp/src/STM32F4Discovery-EXT/bsp.c deleted file mode 100644 --- a/bsp/src/STM32F4Discovery-EXT/bsp.c +++ /dev/null @@ -1,311 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - -float VREF0 =(float)3.3; - -LCD_IF_t lcdIF0={ - .init = &bsp_FSMC_init, - .writereg = &bsp_lcd0_write_reg, - .readreg = &bsp_lcd0_read_reg, - .writeGRAM = &bsp_lcd0_writeGRAM, - .readGRAM = &bsp_lcd0_readGRAM -}; - -LCD_t lcd0={ - .interface = &lcdIF0, - .init = &ssd2119init, - .paint = &ssd2119paint, - .paintText = &ssd2119paintText, - .paintFilRect = &ssd2119paintFilRect, - .refreshenable = &ssd2119refreshenable, - .width= 320, - .height = 240 -}; - - -volatile int16_t* lcd0_CMD=(volatile int16_t*) 0x60000000; -volatile int16_t* lcd0_DATA=(volatile int16_t*)(0x60FFFFF0); - -int bsp_init() -{ - int i=0; - for(i=0;i<32;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - bsp_FSMC_init(); - printf("\r================================================================\n\r"); - printf("================================================================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf("================================================================\n\r"); - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 - // gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); - gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); - // gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); - gpiosetspeed(&gpio1,gpiohighspeed); - //gpiosetspeed(&gpio2,gpiohighspeed); - gpiosetspeed(&gpio3,gpiohighspeed); - //gpiosetspeed(&gpio4,gpiohighspeed); - gpiosetdir(&gpio1,gpiooutdir); - gpiosetdir(&gpio3,gpiooutdir); - // gpiosetdir(&gpio2,gpiooutdir); - //gpiosetdir(&gpio4,gpiooutdir); -} - -void bsp_uart_init() -{ - if(__opnfiles__[1]==NULL) - { - //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - uart_t uart = uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,9600,PC6,PC7,-1,-1); - uartmkstreamdev(uart,fd1); - __opnfiles__[1] = fd1; //stdo - __opnfiles__[0] = fd1; //stdi - } - else - { - uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,9600,PC6,PC7,-1,-1); - } -} - - -/* -D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 -D5 PE8 D6 PE9 D7 PE10 D8 PE11 D9 PE12 -D10 PE13 D11 PE14 D12 PE15 D13 PD8 D14 PD9 -D15 PD10 -A0 PF0 = RS FSMC_NE3 PG10 CS FSMC_NWE PD5 W/S -FSMC_NOE PD4 RD -*/ -/*-- GPIOs Configuration -----------------------------------------------------*/ -/* - +-------------------+--------------------+------------------+------------------+ - + SRAM pins assignment + - +-------------------+--------------------+------------------+------------------+ - | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 | - | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 | - | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 | - | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 | - | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 | - | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 | - | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 | - | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+ - | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 | - | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 | - | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+ - | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 | - | | PE15 <-> FSMC_D12 | - +-------------------+--------------------+ -*/ -int bsp_FSMC_init() -{ -#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) -#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) - - gpio_t gpio1 = gpioopen(LCD_RESET); - gpiosetspeed(&gpio1,gpiohighspeed); - gpiosetdir(&gpio1,gpiooutdir); - gpioclr(LCD_RESET); - gpio1 = gpioopen(LCD_CS); - gpiosetspeed(&gpio1,gpiohighspeed); - gpiosetdir(&gpio1,gpiooutdir); - gpioset(LCD_CS); - gpio_t LCD_DBxList[]={ - PD0 ,PD1 ,PD4 ,PD5 ,PD8 ,PD9 ,PD10,PD14,PD15, - PE3 ,PE7 ,PE8 ,PE9 ,PE10,PE11,PE12,PE13,PE14, - PE15 }; - - for(int i=0;i<19;i++) - { - gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); - LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; - gpiosetconfig(&LCD_DBx); - GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); - } - - FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; - FSMC_NORSRAMTimingInitTypeDef p; - - /* Enable FSMC clock */ - RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); - - /*-- FSMC Configuration ------------------------------------------------------*/ - /*----------------------- SRAM Bank 3 ----------------------------------------*/ - /* FSMC_Bank1_NORSRAM3 configuration */ - p.FSMC_AddressSetupTime = 1; - p.FSMC_AddressHoldTime = 0; - p.FSMC_DataSetupTime = getCpuFreq()/14545450 ;// 11; - p.FSMC_BusTurnAroundDuration = 0; - p.FSMC_CLKDivision = 0; - p.FSMC_DataLatency = 0; - p.FSMC_AccessMode = FSMC_AccessMode_A; - /* Color LCD configuration ------------------------------------ - LCD configured as follow: - - Data/Address MUX = Disable - - Memory Type = SRAM - - Data Width = 16bit - - Write Operation = Enable - - Extended Mode = Enable - - Asynchronous Wait = Disable */ - - FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3; - FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; - FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; - FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; - FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; - FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; - FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; - FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; - FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; - FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; - - FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); - - /* Enable FSMC NOR/SRAM Bank1 */ - FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE); - gpioset(LCD_RESET); - gpioclr(LCD_CS); - lcd0.init(&lcd0); - return 1; -} - -void bsp_spi_init() -{ - -} - - -void bsp_iic_init() -{ - -} - -void bsp_SD_init() -{ - -} - - -void vs10XXclearXCS(){} -void vs10XXsetXCS(){} -int vs10XXDREQ() -{ - return 1; -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return 0; -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) -{ - gpioclr(LCD_CS); - *lcd0_CMD=(uint16_t)reg; - *lcd0_DATA=(uint16_t)data; - gpioset(LCD_CS); -} - -uint32_t bsp_lcd0_read_reg(uint32_t reg) -{ - gpioclr(LCD_CS); - *lcd0_CMD=(uint16_t)reg; - uint32_t data=(uint16_t)*lcd0_DATA; - gpioset(LCD_CS); - return data; -} - -void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) -{ - gpioclr(LCD_CS); - *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; - uint16_t* castedBuff=(uint16_t*)buffer; - for(int i=0;i<(int)count;i++) - { - *lcd0_DATA=castedBuff[i]; - } - gpioset(LCD_CS); -} - -void bsp_lcd0_readGRAM(void* buffer,uint32_t count) -{ - gpioclr(LCD_CS); - *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; - uint16_t* castedBuff=(uint16_t*)buffer; - castedBuff[0]=*lcd0_DATA; - for(int i=0;i<(int)count;i++) - { - castedBuff[i]=*lcd0_DATA; - } - gpioset(LCD_CS); -} - - diff --git a/bsp/src/STM32F4Discovery-EXT/bsp.h b/bsp/src/STM32F4Discovery-EXT/bsp.h deleted file mode 100644 --- a/bsp/src/STM32F4Discovery-EXT/bsp.h +++ /dev/null @@ -1,108 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -#include -#include -#include -/* -#ifndef PD12 - #define PD12 -#endif -#ifndef PD13 - #define PD13 -#endif -*/ -#define __MAX_OPENED_FILES__ 32 -#define __FS_ROOT_SIZE__ 32 - -#define LED1 PD12 -#define LED2 PD13 -#define LCD_RESET PD3 -#define LCD_CS PD7 -#define LCD_BACKL PD13 - -#define GREENLEDON (GPIOD->BSRRL = 1<<12) -#define ORANGELEDON (GPIOD->BSRRL = 1<<13) -#define REDLEDON (GPIOD->BSRRL = 1<<14) -#define BLUELEDON (GPIOD->BSRRL = 1<<15) - -#define GREENLEDOFF (GPIOD->BSRRH = 1<<12) -#define ORANGELEDOFF (GPIOD->BSRRH = 1<<13) -#define REDLEDOFF (GPIOD->BSRRH = 1<<14) -#define BLUELEDOFF (GPIOD->BSRRH = 1<<15) - -extern float VREF0; - -extern uint32_t OSC0; -extern uint32_t currentCpuFreq; - - - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); -extern int bsp_FSMC_init(); - -/* VS1053 */ -extern void clearXCS(); -extern void setXCS(); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); -uint32_t bsp_lcd0_read_reg(uint32_t reg); -void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); -void bsp_lcd0_readGRAM(void *buffer, uint32_t count); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/STM32F4Discovery-EXT/bsp.pri b/bsp/src/STM32F4Discovery-EXT/bsp.pri deleted file mode 100644 --- a/bsp/src/STM32F4Discovery-EXT/bsp.pri +++ /dev/null @@ -1,3 +0,0 @@ -CPU=stm32f4xxxG -DEFINES+=BSP=\\\"STM32F4Discovery-EXT\\\" -UCMODEL=stm32f4 diff --git a/bsp/src/STM32F4Discovery-ILI9328-8bits/STM32F4Discovery-ILI9328-8bits.pro b/bsp/src/STM32F4Discovery-ILI9328-8bits/STM32F4Discovery-ILI9328-8bits.pro deleted file mode 100644 --- a/bsp/src/STM32F4Discovery-ILI9328-8bits/STM32F4Discovery-ILI9328-8bits.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp -CONFIG += bsp gui - -BSP=STM32F4Discovery-ILI9328-8bits - -UCMODEL=stm32f4 - -SOURCES += bsp.c - -HEADERS += bsp.h - -LIBS+= -lgpio -luart -li2c -lspi - -BSPFILE = bsp.pri - - - diff --git a/bsp/src/STM32F4Discovery-ILI9328-8bits/bsp.c b/bsp/src/STM32F4Discovery-ILI9328-8bits/bsp.c deleted file mode 100644 --- a/bsp/src/STM32F4Discovery-ILI9328-8bits/bsp.c +++ /dev/null @@ -1,378 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - -volatile uint8_t* lcd0_CMD=(volatile uint8_t*)0x60000000; -volatile uint8_t* lcd0_DATA=(volatile uint8_t*)0x61FFFFF0; -terminal_t terminal0; -volatile vs10XXDev audioCodec0; -sdcardDev sdcard2; -blkdevice sdcard2blkdev; -dikpartition sdcard2Part1; -FAT32fs sdcard2FAT32part1; -dikpartition sdcard2Part2; -FAT32fs sdcard2FAT32part2; -dikpartition sdcard2Part3; -FAT32fs sdcard2FAT32part3; -dikpartition sdcard2Part4; -FAT32fs sdcard2FAT32part4; - -LCD_IF_t lcdIF0={ - .init = &bsp_FSMC_init, - .writereg = &bsp_lcd0_write_reg, - .readreg = &bsp_lcd0_read_reg, - .writeGRAM = &bsp_lcd0_writeGRAM, - .readGRAM = &bsp_lcd0_readGRAM -}; - -LCD_t lcd0={ - .interface = &lcdIF0, - .init = &ili9328init, - .paint = &ili9328paint, - .paintText = &ili9328paintText, - .paintFilRect = &ili9328paintFilRect, - .refreshenable = &ili9328refreshenable, - .width= 240, - .height = 320 -}; - - -float VREF0 =(float)3.3; - -int bsp_init() -{ - int i=0; - for(i=0;i<32;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - bsp_FSMC_init(); - bsp_GTerm_init(); - printf("\r================================================================\n\r"); - printf("================================================================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf("================================================================\n\r"); - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 - gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); - gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); - gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); - gpiosetspeed(&gpio1,gpiohighspeed); - gpiosetspeed(&gpio2,gpiohighspeed); - gpiosetspeed(&gpio3,gpiohighspeed); - gpiosetspeed(&gpio4,gpiohighspeed); - gpiosetdir(&gpio1,gpiooutdir); - gpiosetdir(&gpio3,gpiooutdir); - gpiosetdir(&gpio2,gpiooutdir); - gpiosetdir(&gpio4,gpiooutdir); -} - -void bsp_uart_init() -{ -// if(__opnfiles__[1]==NULL) -// { -// //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); -// streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); -// uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1); -// uartmkstreamdev(uart,fd1); -// __opnfiles__[1] = fd1; //stdo -// __opnfiles__[0] = fd1; //stdi -// } -// else -// { -// uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); -// } -} - -void bsp_spi_init() -{ - -} - - -int bsp_FSMC_init() -{ -#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) -#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) - - gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10\ - ,PD4,PD5,PD7,PE4}; - for(int i=0;i<12;i++) - { - gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); - LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; - gpiosetconfig(&LCD_DBx); - GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); - } - - FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; - FSMC_NORSRAMTimingInitTypeDef p,readtim; - - /* Enable FSMC clock */ - RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); - - /*-- FSMC Configuration ------------------------------------------------------*/ - /*----------------------- SRAM Bank 3 ----------------------------------------*/ - /* FSMC_Bank1_NORSRAM4 configuration */ - p.FSMC_AddressSetupTime = 3; - p.FSMC_AddressHoldTime = 3; - //ili9328 -> data setup time > 10ns - p.FSMC_DataSetupTime = 1; - if(getCpuFreq()>100*1000*1000) - p.FSMC_DataSetupTime = 2;// 11; - p.FSMC_BusTurnAroundDuration = 0; - p.FSMC_CLKDivision = 0; - p.FSMC_DataLatency = 0; - //ili9328 -> data hold time > 15ns - if(getCpuFreq()>66*1000*1000) - p.FSMC_DataLatency = 1; - p.FSMC_AccessMode = FSMC_AccessMode_A; - - readtim.FSMC_AddressSetupTime = 0xF; - readtim.FSMC_AddressHoldTime = 0xF; - //p.FSMC_DataSetupTime = 9; - readtim.FSMC_DataSetupTime = 0xF ;// 11; - if(getCpuFreq()>100*1000*1000) - readtim.FSMC_DataSetupTime = 0xF;// 11; - readtim.FSMC_BusTurnAroundDuration = 0xf; - readtim.FSMC_CLKDivision = 0; - readtim.FSMC_DataLatency = 0xF; - if(getCpuFreq()>66*1000*1000) - readtim.FSMC_DataLatency = 0xF; - readtim.FSMC_AccessMode = FSMC_AccessMode_A; - - - FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; - FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; - FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; - FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; - FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; - FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; - FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; - FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; - FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readtim; - FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; - - FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); - - FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); - gpioset(LCD_RESET); - gpioclr(LCD_RESET); - delay_100us(500); - gpioset(LCD_RESET); - delay_100us(500); - lcd0.init(&lcd0); - gpioset(LCD_BACKL); - return 1; -} - - -void bsp_iic_init() -{ - -} - -void bsp_SD_init() -{ - -} - - -void vs10XXclearXCS(){} -void vs10XXsetXCS(){} -int vs10XXDREQ() -{ - return 1; -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return 0; -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) -{ - uint8_t* pt8 = (uint8_t*)(void*)® -#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - *lcd0_CMD=pt8[3]; - *lcd0_CMD=pt8[2]; - pt8 = (uint8_t*)(void*)&data; - *lcd0_DATA=pt8[3]; - *lcd0_DATA=pt8[2]; -#else - *lcd0_CMD=pt8[1]; - *lcd0_CMD=pt8[0]; - pt8 = (uint8_t*)(void*)&data; - *lcd0_DATA=pt8[1]; - *lcd0_DATA=pt8[0]; -#endif - -} - -uint32_t bsp_lcd0_read_reg(uint32_t reg) -{ - uint8_t* pt8 = (uint8_t*)(void*)® - uint32_t DATA=0; -#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - *lcd0_CMD=pt8[3]; - *lcd0_CMD=pt8[2]; - pt8 = (uint8_t*)(void*)&DATA; - pt8[3]=*lcd0_DATA; - pt8[2]=*lcd0_DATA; -#else - - *lcd0_CMD=pt8[1]; - *lcd0_CMD=pt8[0]; - pt8 = (uint8_t*)(void*)&DATA; - pt8[1]=*lcd0_DATA; - pt8[0]=*lcd0_DATA; -#endif - - return DATA; -} - -void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) -{ - uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; - uint8_t* pt8 = (uint8_t*)(void*)(®); -#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - *lcd0_CMD=pt8[3]; - *lcd0_CMD=pt8[2]; - pt8 = (uint8_t*)(void*)buffer; - for(int i=0;i<(int)count;i++) - { - *lcd0_DATA=pt8[(2*i) +1]; - *lcd0_DATA=pt8[2*i]; - } -#else - - *lcd0_CMD=pt8[1]; - *lcd0_CMD=pt8[0]; - pt8 = (uint8_t*)(void*)buffer; - for(int i=0;i<(int)count;i++) - { - - *lcd0_DATA=pt8[(2*i) +1]; - *lcd0_DATA=pt8[2*i]; - } -#endif -} - -void bsp_lcd0_readGRAM(void* buffer,uint32_t count) -{ - uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; - uint8_t* pt8 = (uint8_t*)(void*)® -#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - *lcd0_CMD=pt8[3]; - *lcd0_CMD=pt8[2]; - pt8 = (uint8_t*)(void*)buffer; - for(int i=0;i<(int)count;i++) - { - pt8[(2*i) +1]=*lcd0_DATA; - pt8[2*i]=*lcd0_DATA; - } -#else - *lcd0_CMD=pt8[1]; - *lcd0_CMD=pt8[0]; - pt8 = (uint8_t*)(void*)buffer; - /* - * x dummy reads Cf ili9328 datasheet p79! - */ - pt8[0]=*lcd0_DATA; - pt8[0]=*lcd0_DATA; - - for(int i=0;i<(int)count;i++) - { - pt8[(2*i) +1]=*lcd0_DATA; - pt8[2*i]=*lcd0_DATA; - // pt8[(2*i) +1]=(uint8_t)0; - // pt8[(2*i)]=(uint8_t)0; - } -#endif -} - -void bsp_GTerm_init() -{ - if(__opnfiles__[1]==NULL) - { - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); - __opnfiles__[1] = fd1; - } - else - { - - } -} - - - - - diff --git a/bsp/src/STM32F4Discovery-ILI9328-8bits/bsp.h b/bsp/src/STM32F4Discovery-ILI9328-8bits/bsp.h deleted file mode 100644 --- a/bsp/src/STM32F4Discovery-ILI9328-8bits/bsp.h +++ /dev/null @@ -1,127 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* -#ifndef PD12 - #define PD12 -#endif -#ifndef PD13 - #define PD13 -#endif -*/ -#define __MAX_OPENED_FILES__ 32 -#define __FS_ROOT_SIZE__ 32 - -#define LED1 PD12 -#define LED2 PD13 -#define BP3 PA0 - -#define LCD_RESET PD10 -#define LCD_BACKL PE11 - -#define GREENLEDON (GPIOD->BSRRL = 1<<12) -#define ORANGELEDON (GPIOD->BSRRL = 1<<13) -#define REDLEDON (GPIOD->BSRRL = 1<<14) -#define BLUELEDON (GPIOD->BSRRL = 1<<15) - -#define GREENLEDOFF (GPIOD->BSRRH = 1<<12) -#define ORANGELEDOFF (GPIOD->BSRRH = 1<<13) -#define REDLEDOFF (GPIOD->BSRRH = 1<<14) -#define BLUELEDOFF (GPIOD->BSRRH = 1<<15) - -extern float VREF0; -extern LCD_t lcd0; -extern uint32_t OSC0; -extern uint32_t currentCpuFreq; -extern volatile vs10XXDev audioCodec0; -extern sdcardDev sdcard2; -extern blkdevice sdcard2blkdev; -extern dikpartition sdcard2Part1; -extern FAT32fs sdcard2FAT32part1; -extern dikpartition sdcard2Part2; -extern FAT32fs sdcard2FAT32part2; -extern dikpartition sdcard2Part3; -extern FAT32fs sdcard2FAT32part3; -extern dikpartition sdcard2Part4; -extern FAT32fs sdcard2FAT32part4; - - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); -extern void bsp_GTerm_init(); -extern int bsp_FSMC_init(); - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); -uint32_t bsp_lcd0_read_reg(uint32_t reg); -void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); -void bsp_lcd0_readGRAM(void *buffer, uint32_t count); - -/* VS1053 */ -extern void clearXCS(); -extern void setXCS(); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/STM32F4Discovery-ILI9328-8bits/bsp.pri b/bsp/src/STM32F4Discovery-ILI9328-8bits/bsp.pri deleted file mode 100644 --- a/bsp/src/STM32F4Discovery-ILI9328-8bits/bsp.pri +++ /dev/null @@ -1,3 +0,0 @@ -CPU=stm32f4xxxG -DEFINES+=BSP=\\\"STM32F4Discovery-ILI9328-8bits\\\" -UCMODEL=stm32f4 diff --git a/bsp/src/STM32F4Discovery/STM32F4Discovery.pro b/bsp/src/STM32F4Discovery/STM32F4Discovery.pro deleted file mode 100644 --- a/bsp/src/STM32F4Discovery/STM32F4Discovery.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp -CONFIG += bsp - -BSP=STM32F4Discovery - -UCMODEL=stm32f4 - -SOURCES += bsp.c - -HEADERS += bsp.h - -LIBS+= -lgpio -luart -li2c -lspi - -BSPFILE = bsp.pri - - - diff --git a/bsp/src/STM32F4Discovery/bsp.c b/bsp/src/STM32F4Discovery/bsp.c deleted file mode 100644 --- a/bsp/src/STM32F4Discovery/bsp.c +++ /dev/null @@ -1,134 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - -float VREF0 =(float)3.3; - -int bsp_init() -{ - int i=0; - for(i=0;i<32;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - printf("\r================================================================\n\r"); - printf("================================================================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf("================================================================\n\r"); - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 - gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); - gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); - gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); - gpiosetspeed(&gpio1,gpiohighspeed); - gpiosetspeed(&gpio2,gpiohighspeed); - gpiosetspeed(&gpio3,gpiohighspeed); - gpiosetspeed(&gpio4,gpiohighspeed); - gpiosetdir(&gpio1,gpiooutdir); - gpiosetdir(&gpio3,gpiooutdir); - gpiosetdir(&gpio2,gpiooutdir); - gpiosetdir(&gpio4,gpiooutdir); -} - -void bsp_uart_init() -{ - if(__opnfiles__[1]==NULL) - { - //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1); - uartmkstreamdev(uart,fd1); - __opnfiles__[1] = fd1; //stdo - __opnfiles__[0] = fd1; //stdi - } - else - { - uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); - } -} - -void bsp_spi_init() -{ - -} - - -void bsp_iic_init() -{ - -} - -void bsp_SD_init() -{ - -} - - -void vs10XXclearXCS(){} -void vs10XXsetXCS(){} -int vs10XXDREQ() -{ - return 1; -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return 0; -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - - - - - diff --git a/bsp/src/STM32F4Discovery/bsp.h b/bsp/src/STM32F4Discovery/bsp.h deleted file mode 100644 --- a/bsp/src/STM32F4Discovery/bsp.h +++ /dev/null @@ -1,95 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -/* -#ifndef PD12 - #define PD12 -#endif -#ifndef PD13 - #define PD13 -#endif -*/ -#define __MAX_OPENED_FILES__ 32 -#define __FS_ROOT_SIZE__ 32 - -#define LED1 PD12 -#define LED2 PD13 - -#define GREENLEDON (GPIOD->BSRRL = 1<<12) -#define ORANGELEDON (GPIOD->BSRRL = 1<<13) -#define REDLEDON (GPIOD->BSRRL = 1<<14) -#define BLUELEDON (GPIOD->BSRRL = 1<<15) - -#define GREENLEDOFF (GPIOD->BSRRH = 1<<12) -#define ORANGELEDOFF (GPIOD->BSRRH = 1<<13) -#define REDLEDOFF (GPIOD->BSRRH = 1<<14) -#define BLUELEDOFF (GPIOD->BSRRH = 1<<15) - -extern float VREF0; - -extern uint32_t OSC0; -extern uint32_t currentCpuFreq; - - - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); - -/* VS1053 */ -extern void clearXCS(); -extern void setXCS(); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/STM32F4Discovery/bsp.pri b/bsp/src/STM32F4Discovery/bsp.pri deleted file mode 100644 --- a/bsp/src/STM32F4Discovery/bsp.pri +++ /dev/null @@ -1,3 +0,0 @@ -CPU=stm32f4xxxG -DEFINES+=BSP=\\\"STM32F4Discovery\\\" -UCMODEL=stm32f4 diff --git a/bsp/src/STM32F4Eval/STM32F4Eval.pro b/bsp/src/STM32F4Eval/STM32F4Eval.pro deleted file mode 100644 --- a/bsp/src/STM32F4Eval/STM32F4Eval.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = lib - -TARGET=bsp -CONFIG += bsp gui - -BSP=STM32F4Eval - -UCMODEL=stm32f4 - -SOURCES += bsp.c - -HEADERS += bsp.h -LIBS+= -lgpio -luart -li2c -lspi - -BSPFILE = bsp.pri - - - diff --git a/bsp/src/STM32F4Eval/bsp.c b/bsp/src/STM32F4Eval/bsp.c deleted file mode 100644 --- a/bsp/src/STM32F4Eval/bsp.c +++ /dev/null @@ -1,363 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#include "bsp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -uint32_t OSC0 =8000000; -uint32_t INTOSC =16000000; -uint32_t RTCOSC =32768; -uint32_t currentCpuFreq=0; -extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; - -LCD_IF_t lcdIF0={ - .init = &bsp_FSMC_init, - .writereg = &bsp_lcd0_write_reg, - .readreg = &bsp_lcd0_read_reg, - .writeGRAM = &bsp_lcd0_writeGRAM, - .readGRAM = &bsp_lcd0_readGRAM -}; - -LCD_t lcd0={ - .interface = &lcdIF0, - .init = &ili9328init, - .paint = &ili9328paint, - .paintText = &ili9328paintText, - .paintFilRect = &ili9328paintFilRect, - .getPix = &ili9328getPix, - .refreshenable = &ili9328refreshenable, - .width= 240, - .height = 320 -}; - -terminal_t terminal0; - - -volatile int16_t* lcd0_CMD=(volatile int16_t*) (0x60000000 | 0x08000000); -volatile int16_t* lcd0_DATA=((volatile int16_t*)(0x60000000 | 0x08000002)); - -float VREF0 =(float)3.3; - -int bsp_init() -{ - int i=0; - for(i=0;i<32;i++) - { - __opnfiles__[i] = NULL; - } - bsp_GPIO_init(); - bsp_uart_init(); - bsp_iic_init(); - bsp_FSMC_init(); - bsp_GTerm_init(); - printf("\r=====================\n\r"); - printf( "=====================\n\r"); - printf(BSP); - printf(" initialised\n\r"); - printf( "=====================\n\r"); - return 1; -} - -void bsp_GPIO_init() -{ - gpio_t gpio1 = gpioopen(LED1); - gpio_t gpio2 = gpioopen(LED2); - gpio_t gpio3 = gpioopen(LED3); - gpiosetspeed(&gpio1,gpiohighspeed); - gpiosetspeed(&gpio2,gpiohighspeed); - gpiosetspeed(&gpio3,gpiohighspeed); - gpiosetdir(&gpio1,gpiooutdir); - gpiosetdir(&gpio2,gpiooutdir); - gpiosetdir(&gpio3,gpiooutdir); -} - -void bsp_uart_init() -{ - //if(__opnfiles__[1]==NULL) - //{ - //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); - // 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; - //} - //else - //{ - uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); - //} -} - -/* -D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 -D5 PE8 D6 PE9 D7 PE10 D8 PE11 D9 PE12 -D10 PE13 D11 PE14 D12 PE15 D13 PD8 D14 PD9 -D15 PD10 -A0 PF0 = RS FSMC_NE3 PG10 CS FSMC_NWE PD5 W/S -FSMC_NOE PD4 RD -*/ -/*-- GPIOs Configuration -----------------------------------------------------*/ -/* - +-------------------+--------------------+------------------+------------------+ - + SRAM pins assignment + - +-------------------+--------------------+------------------+------------------+ - | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 | - | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 | - | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 | - | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 | - | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 | - | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 | - | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 | - | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+ - | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 | - | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 | - | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+ - | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 | - | | PE15 <-> FSMC_D12 | - +-------------------+--------------------+ -*/ -int bsp_FSMC_init() -{ -#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) -#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) - - gpio_t LCD_DBxList[]={ - PD0 ,PD1 ,PD4 ,PD5 ,PD8 ,PD9 ,PD10,PD11,PD12,PD13,PD14,PD15, - PE0 ,PE1 ,PE3 ,PE4 ,PE7 ,PE8 ,PE9 ,PE10,PE11,PE12,PE13,PE14, - PE15,PF0 ,PF1 ,PF2 ,PF3 ,PF4 ,PF5 ,PF12,PF13,PF14,PF15,PG0 , - PG1 ,PG2 ,PG3 ,PG4 ,PG5 ,PG9 ,PG10 - }; - - for(int i=0;i<43;i++) - { - gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); - LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; - gpiosetconfig(&LCD_DBx); - GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); - } - - FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; - FSMC_NORSRAMTimingInitTypeDef p,readtim; - - /* Enable FSMC clock */ - RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); - - /*-- FSMC Configuration ------------------------------------------------------*/ - /*----------------------- SRAM Bank 3 ----------------------------------------*/ - /* FSMC_Bank1_NORSRAM3 configuration */ - p.FSMC_AddressSetupTime = 0xf; - p.FSMC_AddressHoldTime = 0xf; - //ili9328 -> data setup time > 10ns - p.FSMC_DataSetupTime = 0xf; - if(getCpuFreq()>100*1000*1000) - p.FSMC_DataSetupTime = 0xf;// 11; - p.FSMC_BusTurnAroundDuration = 0xf; - p.FSMC_CLKDivision = 0; - p.FSMC_DataLatency = 0xf; - //ili9328 -> data hold time > 15ns - if(getCpuFreq()>66*1000*1000) - p.FSMC_DataLatency = 0xf; - p.FSMC_AccessMode = FSMC_AccessMode_A; - - readtim.FSMC_AddressSetupTime = 0xf; - readtim.FSMC_AddressHoldTime = 0xf; - //p.FSMC_DataSetupTime = 9; - readtim.FSMC_DataSetupTime = 0xf ;// 11; - if(getCpuFreq()>100*1000*1000) - readtim.FSMC_DataSetupTime = 0xf;// 11; - readtim.FSMC_BusTurnAroundDuration = 0xf; - readtim.FSMC_CLKDivision = 0; - readtim.FSMC_DataLatency = 0xf; - if(getCpuFreq()>66*1000*1000) - readtim.FSMC_DataLatency = 0xf; - readtim.FSMC_AccessMode = FSMC_AccessMode_A; - /* Color LCD configuration ------------------------------------ - LCD configured as follow: - - Data/Address MUX = Disable - - Memory Type = SRAM - - Data Width = 16bit - - Write Operation = Enable - - Extended Mode = Enable - - Asynchronous Wait = Disable */ - - FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3; - FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; - FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; - FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; - FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; - FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; - FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; - FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; - FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readtim; - FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; - - FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); - - /* Enable FSMC NOR/SRAM Bank1 */ - FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE); - - - p.FSMC_AddressSetupTime = getCpuFreq()/50000000; - p.FSMC_AddressHoldTime = 0; - p.FSMC_DataSetupTime = getCpuFreq()/25000000; - p.FSMC_BusTurnAroundDuration = 1; - p.FSMC_CLKDivision = 0; - p.FSMC_DataLatency = 0; - p.FSMC_AccessMode = FSMC_AccessMode_A; - - FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2; - FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; - FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM; - FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; - FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; - FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; - FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; - FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; - FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; - FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; - - FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); - - /*!< Enable FSMC Bank1_SRAM2 Bank */ - FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM2, ENABLE); - lcd0.init(&lcd0); - return 1; -} - -void bsp_spi_init() -{ - -} - - -void bsp_iic_init() -{ - i2copenandconfig(i2c1,0,10000,PB9,PB6); -} - -void bsp_SD_init() -{ - gpio_t SDIO_DBxList[]={PC8 ,PC9 ,PC10 ,PC11 ,PC12,PD2}; - for(int i=0;i<6;i++) - { - gpio_t SDIO_DBx = gpioopen(SDIO_DBxList[i]); - SDIO_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; - gpiosetconfig(&SDIO_DBx); - GPIO_PinAFConfig(GPIOGETPORT(SDIO_DBx), (uint8_t)(SDIO_DBx & 0xF), GPIO_AF_SDIO); - } -} - -void vs10XXclearXCS(){} -void vs10XXsetXCS(){} -int vs10XXDREQ() -{ - return 1; -} - - -void bsppowersdcard(char onoff) //always ON -{ - -} - -char bspsdcardpresent() -{ - return 0; -} - -char bspsdcardwriteprotected() -{ - return 0; -} - -void bspsdcardselect(char YESNO) -{ - -} - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) -{ - *lcd0_CMD=(uint16_t)reg; - *lcd0_DATA=(uint16_t)data; -} - -uint32_t bsp_lcd0_read_reg(uint32_t reg) -{ - *lcd0_CMD=(uint16_t)reg; - return (uint16_t)*lcd0_DATA; -} - -void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) -{ - *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; - uint16_t* castedBuff=(uint16_t*)buffer; - for(int i=0;i<(int)count;i++) - { - *lcd0_DATA=castedBuff[i]; - } -} - -void bsp_lcd0_readGRAM(void* buffer,uint32_t count) -{ - *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; - uint16_t* castedBuff=(uint16_t*)buffer; - castedBuff[0]=*lcd0_DATA; - for(int i=0;i<(int)count;i++) - { - castedBuff[i]=*lcd0_DATA; - } -} - -void bsp_GTerm_init() -{ - if(__opnfiles__[1]==NULL) - { - streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); - ili9328paintFilRect(&lcd0,0,0,240,320,0x7FFF,5,0); - terminal_init(&terminal0,&lcd0,&ComicSansMS_8,fd1); - __opnfiles__[1] = fd1; - } - else - { - - } -} - - - diff --git a/bsp/src/STM32F4Eval/bsp.h b/bsp/src/STM32F4Eval/bsp.h deleted file mode 100644 --- a/bsp/src/STM32F4Eval/bsp.h +++ /dev/null @@ -1,94 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2011, Alexis Jeandet --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------- --- Author : Alexis Jeandet --- Mail : alexis.jeandet@member.fsf.org --------------------------------------------------------------------------------*/ -#ifndef BSP_H -#define BSP_H -#include -#include -#include -#include -#include -#include - -#define __MAX_OPENED_FILES__ 4 -#define __FS_ROOT_SIZE__ 4 - - - -#define LED1 PG6 -#define LED2 PG8 -#define LED3 PI9 -#define LED4 PC7 - - -extern float VREF0; - -extern uint32_t currentCpuFreq; -extern LCD_t lcd0; - - -extern int bsp_init(); - -extern void bsp_GPIO_init(); -extern void bsp_uart_init(); -extern void bsp_iic_init(); -extern void bsp_spi_init(); -extern void bsp_SD_init(); -extern void bsp_GTerm_init(); -extern int bsp_FSMC_init(); - -/* VS1053 */ -extern void clearXCS(); -extern void setXCS(); -extern int vs10XXDREQ(); - -/* SD CARD */ -void bsppowersdcard(char onoff); -char bspsdcardpresent(); -void bspsdcardselect(char YESNO); -char bspsdcardwriteprotected(); - - -void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); -uint32_t bsp_lcd0_read_reg(uint32_t reg); -void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); -void bsp_lcd0_readGRAM(void *buffer, uint32_t count); - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/bsp/src/STM32F4Eval/bsp.pri b/bsp/src/STM32F4Eval/bsp.pri deleted file mode 100644 --- a/bsp/src/STM32F4Eval/bsp.pri +++ /dev/null @@ -1,3 +0,0 @@ -CPU=stm32f4xxxG -DEFINES+=BSP=\\\"STM32F4Eval\\\" -UCMODEL=stm32f4 diff --git a/bsp/src/bsp.pro b/bsp/src/bsp.pro --- a/bsp/src/bsp.pro +++ b/bsp/src/bsp.pro @@ -1,21 +1,17 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += STM32F4Discovery \ - M4Stick \ - M4StickV2 \ - SOLAR_LFR_PSU \ - BEAGLESYNTH \ - STM32F4Eval \ - STM32F4Discovery-EXT \ - STM32F4Discovery-ILI9328-8bits \ - OPLAYER \ - SIMULATOR \ - STM32-E407 \ - STM32F429Discovery + +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + SUBDIRS += stm32f4 + } + contains( UCMODEL, simulator ){ + SUBDIRS += simulator + } +} - diff --git a/bsp/src/simulator/SIMULATOR/SIMULATOR.pro b/bsp/src/simulator/SIMULATOR/SIMULATOR.pro new file mode 100644 --- /dev/null +++ b/bsp/src/simulator/SIMULATOR/SIMULATOR.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp gui fs + + +BSP = SIMULATOR + +UCMODEL=simulator + +SOURCES += bsp.c + +HEADERS += bsp.h + +LIBS+= -lgpio -luart -li2c -lspi +BSPFILE = bsp.pri + +OTHER_FILES += bsp.pri + + diff --git a/bsp/src/simulator/SIMULATOR/bsp.c b/bsp/src/simulator/SIMULATOR/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/simulator/SIMULATOR/bsp.c @@ -0,0 +1,332 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include + + +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + + +LCD_IF_t lcdIF0={ + .init = &SDLCD_init, + .writereg = &SDLCD_writereg, + .readreg = &SDLCD_readreg, + .writeGRAM = &SDLCD_writeGRAM_16bpp, + .readGRAM = &SDLCD_readGRAM_16bpp +}; + +LCD_t lcd0={ + .interface = &lcdIF0, + .init = &ili9328init, + .paint = &ili9328paint, + .paintText = &ili9328paintText, + .paintFilRect = &ili9328paintFilRect, + .getPix = &ili9328getPix, + .refreshenable = &ili9328refreshenable, + .width= 240, + .height = 320 +}; + +terminal_t terminal0; + +volatile int8_t* lcd0_CMD=(volatile int8_t*) 0x60000000; +volatile int8_t* lcd0_DATA=(volatile int8_t*)(0x61FFFFF0); + +float VREF0 =(float)3.3; +volatile vs10XXDev audioCodec0; + +sdcardDev sdcard2; +blkdevice sdcard2blkdev; +dikpartition sdcard2Part1; +FAT32fs sdcard2FAT32part1; +dikpartition sdcard2Part2; +FAT32fs sdcard2FAT32part2; +dikpartition sdcard2Part3; +FAT32fs sdcard2FAT32part3; +dikpartition sdcard2Part4; +FAT32fs sdcard2FAT32part4; + +int bsp_init() +{ + int i=0; + for(i=0;i<__MAX_OPENED_FILES__;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + bsp_iic_init(); + bsp_FSMC_init(); + bsp_GTerm_init(); + bsp_spi_init(); + bsp_SD_init(); + bsp_Audio_init(); + printf("\r=====================\n\r"); + printf( "=====================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf( "=====================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + +} + +void bsp_uart_init() +{ + +} + +/* +D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 +D5 PE8 D6 PE9 D7 PE10 +A20 PE4 = RS FSMC_NE1 PD7 CS FSMC_NWE PD5 W/S +FSMC_NOE PD4 RD +*/ + +int bsp_FSMC_init() +{ + + return 1; +} + +void bsp_spi_init() +{ + +} + + +void bsp_iic_init() +{ + +} + + +void bsp_Audio_init() +{ + +} + +void bsp_SD_init() +{ + sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2, bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); + if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT) + { + if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1)) + printf("Can't open fat32 partition 1\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + delay_100us(1000); + if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2)) + printf("Can't open fat32 partition 2\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + delay_100us(1000); + if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3)) + printf("Can't open fat32 partition 3\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + delay_100us(1000); + if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4)) + printf("Can't open fat32 partition 4\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + } + else + { + printf("Can't initialize SDCARD\n"); + } + + delay_100us(2000); +} + +void vs1052setXCS(char val) +{ +} + +void vs1052setXDCS(char val) +{ +} + +void vs1052setRST(char val) +{ +} + +int vs10XXDREQ() +{ + return 1; +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return 1; +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) +{ + +} + +uint32_t bsp_lcd0_read_reg(uint32_t reg) +{ + return 0; +} + +void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) +{ + +} + +void bsp_lcd0_readGRAM(void* buffer,uint32_t count) +{ + +} + +void bsp_GTerm_init() +{ + SDLCD_mkscreen(240,320,16,LCDILI9328); + + if(__opnfiles__[1]==NULL) + { + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + terminal_init(&terminal0 ,&lcd0,&ComicSansMS_18,fd1); + lcd0.paintFilRect(&lcd0,0,0,240,320,0,0,0x0f0f); + __opnfiles__[1] = fd1; + } + else + { + + } +} + + + + + + + +void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel) +{ + int bpp = surface->format->BytesPerPixel; + /* Here p is the address to the pixel we want to set */ + Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + switch(bpp) { + case 1: + *p = pixel; + break; + case 2: + *(Uint16 *)p = pixel; + break; + case 3: + if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { + p[0] = (pixel >> 16) & 0xff; + p[1] = (pixel >> 8) & 0xff; + p[2] = pixel & 0xff; + } else { + p[0] = pixel & 0xff; + p[1] = (pixel >> 8) & 0xff; + p[2] = (pixel >> 16) & 0xff; + } + break; + case 4: + *(Uint32 *)p = pixel; + break; + } +} + +Uint32 getpixel(SDL_Surface *surface, int x, int y) +{ + int bpp = surface->format->BytesPerPixel; + /* Here p is the address to the pixel we want to retrieve */ + Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + switch(bpp) { + case 1: + return *p; + case 2: + return *(Uint16 *)p; + case 3: + if(SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; + else + return p[0] | p[1] << 8 | p[2] << 16; + case 4: + return *(Uint32 *)p; + default: + return 0; + } + /* shouldn’t happen, but avoids warnings */ +} + + + + + + + + + + diff --git a/bsp/src/simulator/SIMULATOR/bsp.h b/bsp/src/simulator/SIMULATOR/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/simulator/SIMULATOR/bsp.h @@ -0,0 +1,139 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define __MAX_OPENED_FILES__ 4 +#define __FS_ROOT_SIZE__ 4 + + +#define LED1 PC15 +#define LED2 PC14 + +#define BP3 PA0 + +#define LCD_RESET PD10 +#define LCD_BACKL PE11 + +#define VS1053SPI spi1 +#define VS1053xCS PA3 +#define VS1053xRESET PA2 +#define VS1053xDCS PA4 +#define VS1053DREQ PA1 +#define VS1053MISO PA6 +#define VS1053MOSI PA7 +#define VS1053SCK PA5 + + + +#define SDCARD2SPI spi3 +#define SDCARD2CS PB8 +#define SDCARD2CD PB9 +#define SDCARD2MISO PB4 +#define SDCARD2MOSI PB5 +#define SDCARD2SCK PB3 + +extern float VREF0; + +extern uint32_t currentCpuFreq; +extern LCD_t lcd0; + +extern volatile vs10XXDev audioCodec0; + +extern sdcardDev sdcard2; +extern blkdevice sdcard2blkdev; +extern dikpartition sdcard2Part1; +extern FAT32fs sdcard2FAT32part1; +extern dikpartition sdcard2Part2; +extern FAT32fs sdcard2FAT32part2; +extern dikpartition sdcard2Part3; +extern FAT32fs sdcard2FAT32part3; +extern dikpartition sdcard2Part4; +extern FAT32fs sdcard2FAT32part4; + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); +extern void bsp_Audio_init(); +extern void bsp_GTerm_init(); +extern int bsp_FSMC_init(); + +/* VS1053 */ +extern void vs1052setXCS(char val); +extern void vs1052setXDCS(char val); +extern void vs1052setRST(char val); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); +uint32_t bsp_lcd0_read_reg(uint32_t reg); +void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); +void bsp_lcd0_readGRAM(void *buffer, uint32_t count); + + +extern void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel); +extern Uint32 getpixel(SDL_Surface *surface, int x, int y); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/simulator/SIMULATOR/bsp.pri b/bsp/src/simulator/SIMULATOR/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/simulator/SIMULATOR/bsp.pri @@ -0,0 +1,6 @@ +CPU=simultor +DEFINES+=BSP=\\\"SIMULATOR\\\" + +UCMODEL=simulator + +LIBS+=-lSDLCD diff --git a/bsp/src/simulator/simulator.pro b/bsp/src/simulator/simulator.pro new file mode 100644 --- /dev/null +++ b/bsp/src/simulator/simulator.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS += SIMULATOR + + + + + + diff --git a/bsp/src/stm32f4/BEAGLESYNTH/BEAGLESYNTH.pro b/bsp/src/stm32f4/BEAGLESYNTH/BEAGLESYNTH.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/BEAGLESYNTH/BEAGLESYNTH.pro @@ -0,0 +1,22 @@ +TEMPLATE = lib + +TARGET=bsp + +CONFIG += bsp +CONFIG += gui power + +BSP = BEAGLESYNTH + +UCMODEL=stm32f4 + +SOURCES += bsp.c + +HEADERS += bsp.h + +LIBS+= -lgpio -luart -li2c -lspi + + +BSPFILE = bsp.pri + + + diff --git a/bsp/src/stm32f4/BEAGLESYNTH/bsp.c b/bsp/src/stm32f4/BEAGLESYNTH/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/BEAGLESYNTH/bsp.c @@ -0,0 +1,313 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + +LCD_IF_t lcdIF0={ + .init = &bsp_FSMC_init, + .writereg = &bsp_lcd0_write_reg, + .readreg = &bsp_lcd0_read_reg, + .writeGRAM = &bsp_lcd0_writeGRAM, + .readGRAM = &bsp_lcd0_readGRAM +}; + +LCD_t lcd0={ + .interface = &lcdIF0, + .init = &ili9328init, + .paint = &ili9328paint, + .paintText = &ili9328paintText, + .paintFilRect = &ili9328paintFilRect, + .getPix = &ili9328getPix, + .refreshenable = &ili9328refreshenable, + .width= 240, + .height = 320 +}; + +terminal_t terminal0; + +volatile int16_t* lcd0_CMD=(volatile int16_t*)0x60000000; +volatile int16_t* lcd0_DATA=(volatile int16_t*)0x61FFFFF0; + +float VREF0 =(float)3.3; + +int bsp_init() +{ + int i=0; + for(i=0;i<32;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + bsp_iic_init(); + bsp_FSMC_init(); + bsp_GTerm_init(); + printf("\r=====================\n\r"); + printf( "=====================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf( "=====================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t gpio1 = gpioopen(LED1); + gpio_t gpio2 = gpioopen(LED2); + gpio_t gpio3 = gpioopen(LED3); + gpio_t gpio4 = gpioopen(PSU_DISABLE); + gpio_t gpio5 = gpioopen(PSU_ALERT_5V); + gpio_t gpio6 = gpioopen(PSU_ALERT_1_5V); + gpio_t gpio7 = gpioopen(PSU_ALERT_3_3V); + gpiosetspeed(&gpio1,gpiohighspeed); + gpiosetspeed(&gpio2,gpiohighspeed); + gpiosetspeed(&gpio3,gpiohighspeed); + gpiosetspeed(&gpio4,gpiohighspeed); + gpiosetspeed(&gpio5,gpiohighspeed); + gpiosetspeed(&gpio6,gpiohighspeed); + gpiosetspeed(&gpio7,gpiohighspeed); + gpioclr(PSU_DISABLE); + gpiosetdir(&gpio1,gpiooutdir); + gpiosetdir(&gpio3,gpiooutdir); + gpiosetdir(&gpio2,gpiooutdir); + gpiosetdir(&gpio4,gpiooutdir); + gpiosetdir(&gpio5,gpioindir); + gpiosetdir(&gpio6,gpioindir); + gpiosetdir(&gpio7,gpioindir); + gpioclr(PSU_DISABLE); +} + +void bsp_uart_init() +{ + //if(__opnfiles__[1]==NULL) + //{ + //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); + // 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; + //} + //else + //{ + uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); + //} +} + + + +int bsp_FSMC_init() +{ +#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) +#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) + + gpio_t gpio1 = gpioopen(LCD_RESET); + gpiosetspeed(&gpio1,gpiohighspeed); + gpiosetdir(&gpio1,gpiooutdir); + gpioclr(LCD_RESET); + + gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10,PE11,PE12,PE13,PE14,PE15\ + ,PD8,PD9,PD10,PD4,PD5,PD7,PE4}; + for(int i=0;i<20;i++) + { + gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); + LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; + gpiosetconfig(&LCD_DBx); + GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); + } + + FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; + FSMC_NORSRAMTimingInitTypeDef p; + + /* Enable FSMC clock */ + RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); + + /*-- FSMC Configuration ------------------------------------------------------*/ + /*----------------------- SRAM Bank 3 ----------------------------------------*/ + /* FSMC_Bank1_NORSRAM4 configuration */ + //p.FSMC_AddressSetupTime = 5; + p.FSMC_AddressSetupTime = 1; + p.FSMC_AddressHoldTime = 0; + //p.FSMC_DataSetupTime = 9; + p.FSMC_DataSetupTime = getCpuFreq()/14545450 ;// 11; + p.FSMC_BusTurnAroundDuration = 0; + p.FSMC_CLKDivision = 0; + p.FSMC_DataLatency = 0; + p.FSMC_AccessMode = FSMC_AccessMode_A; + /* Color LCD configuration ------------------------------------ + LCD configured as follow: + - Data/Address MUX = Disable + - Memory Type = SRAM + - Data Width = 16bit + - Write Operation = Enable + - Extended Mode = Enable + - Asynchronous Wait = Disable */ + + FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; + FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; + FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; + FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; + FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; + FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; + FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; + FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; + FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; + FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; + + FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); + + /* Enable FSMC NOR/SRAM Bank1 */ + FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); + gpioset(LCD_RESET); + lcd0.init(&lcd0); + return 1; +} + +void bsp_spi_init() +{ + +} + + +void bsp_iic_init() +{ + i2copenandconfig(i2c2,0,10000,PF0,PF1); +} + +void bsp_SD_init() +{ + +} + +void vs10XXclearXCS(){} +void vs10XXsetXCS(){} +int vs10XXDREQ() +{ + return 1; +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return 0; +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) +{ + *lcd0_CMD=(uint16_t)reg; + *lcd0_DATA=(uint16_t)data; +} + +uint32_t bsp_lcd0_read_reg(uint32_t reg) +{ + *lcd0_CMD=(uint16_t)reg; + return (uint16_t)*lcd0_DATA; +} + +void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) +{ + *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; + uint16_t* castedBuff=(uint16_t*)buffer; + for(int i=0;i<(int)count;i++) + { + *lcd0_DATA=castedBuff[i]; + } +} + +void bsp_lcd0_readGRAM(void* buffer,uint32_t count) +{ + *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; + uint16_t* castedBuff=(uint16_t*)buffer; + castedBuff[0]=*lcd0_DATA; + for(int i=0;i<(int)count;i++) + { + castedBuff[i]=*lcd0_DATA; + } +} + + +void bsp_GTerm_init() +{ + if(__opnfiles__[1]==NULL) + { + //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); + __opnfiles__[1] = fd1; + } + else + { + + } +} + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/BEAGLESYNTH/bsp.h b/bsp/src/stm32f4/BEAGLESYNTH/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/BEAGLESYNTH/bsp.h @@ -0,0 +1,106 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +#include +#include +#include +#include + +#define __MAX_OPENED_FILES__ 4 +#define __FS_ROOT_SIZE__ 4 +/* +#ifndef PD8 + #define PD8 +#endif +#ifndef PD9 + #define PD9 +#endif +*/ + + +#define LED1 PF6 +#define LED2 PF7 +#define LED3 PF8 + +#define PSU_DISABLE PH2 +#define PSU_ALERT_5V PF2 +#define PSU_ALERT_1_5V PF3 +#define PSU_ALERT_3_3V PF4 + +#define LCD_RESET PE2 + +extern float VREF0; + +extern uint32_t currentCpuFreq; +extern LCD_t lcd0; + + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); +extern void bsp_GTerm_init(); +extern int bsp_FSMC_init(); + +/* VS1053 */ +extern void clearXCS(); +extern void setXCS(); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); +uint32_t bsp_lcd0_read_reg(uint32_t reg); +void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); +void bsp_lcd0_readGRAM(void *buffer, uint32_t count); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/BEAGLESYNTH/bsp.pri b/bsp/src/stm32f4/BEAGLESYNTH/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/BEAGLESYNTH/bsp.pri @@ -0,0 +1,9 @@ +CPU=stm32f4xxxG +DEFINES+=BSP=\\\"BEAGLESYNTH\\\" +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 + +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/M4Stick/M4Stick.pro b/bsp/src/stm32f4/M4Stick/M4Stick.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4Stick/M4Stick.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib + +TARGET=bsp + +CONFIG += bsp +BSP=M4Stick + +UCMODEL=stm32f4 + +SOURCES += bsp.c + +HEADERS += bsp.h +LIBS+= -lgpio -luart -li2c -lspi + +BSPFILE = bsp.pri + + + diff --git a/bsp/src/stm32f4/M4Stick/bsp.c b/bsp/src/stm32f4/M4Stick/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4Stick/bsp.c @@ -0,0 +1,126 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + +float VREF0 =(float)3.3; + +int bsp_init() +{ + int i=0; + for(i=0;i<32;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + printf("\r================================================================\n\r"); + printf("================================================================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf("================================================================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t gpio1 = gpioopen(PC6);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 + gpio_t gpio2 = gpioopen(PC7);//gpioopen(LED2); + gpiosetspeed(&gpio1,gpiohighspeed); + gpiosetspeed(&gpio2,gpiohighspeed); + gpiosetdir(&gpio1,gpiooutdir); + gpiosetdir(&gpio2,gpiooutdir); +} + +void bsp_uart_init() +{ + if(__opnfiles__[1]==NULL) + { + //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,LED2,LED1,-1,-1); + uartmkstreamdev(uart,fd1); + __opnfiles__[1] = fd1; + } + else + { + uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,LED2,LED1,-1,-1); + } +} + +void bsp_spi_init() +{ + +} + + +void bsp_iic_init() +{ + +} + +void bsp_SD_init() +{ + +} + +void vs10XXclearXCS(){} +void vs10XXsetXCS(){} +int vs10XXDREQ() +{ + return 1; +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return 0; +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + + + + + diff --git a/bsp/src/stm32f4/M4Stick/bsp.h b/bsp/src/stm32f4/M4Stick/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4Stick/bsp.h @@ -0,0 +1,86 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +#include +#include + + +#define __MAX_OPENED_FILES__ 32 +#define __FS_ROOT_SIZE__ 32 + +#define LED1 PD8 +#define LED2 PD9 + +#define LED3ON GPIOB->BSRRH = GPIO_Pin_15 +#define LED2ON GPIOD->BSRRH = GPIO_Pin_8 +#define LED1ON GPIOD->BSRRH = GPIO_Pin_9 + +#define LED3OFF GPIOB->BSRRL = GPIO_Pin_15 +#define LED2OFF GPIOD->BSRRL = GPIO_Pin_8 +#define LED1OFF GPIOD->BSRRL = GPIO_Pin_9 + +extern float VREF0; + +extern uint32_t currentCpuFreq; + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); + +/* VS1053 */ +extern void clearXCS(); +extern void setXCS(); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/M4Stick/bsp.pri b/bsp/src/stm32f4/M4Stick/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4Stick/bsp.pri @@ -0,0 +1,3 @@ +CPU=stm32f4xxxG +DEFINES+=BSP=\\\"M4Stick\\\" +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/M4StickV2/M4StickV2.pro b/bsp/src/stm32f4/M4StickV2/M4StickV2.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/M4StickV2.pro @@ -0,0 +1,35 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp + +BSP=M4StickV2 + + +UCMODEL=stm32f4 + +SOURCES += bsp.c + +HEADERS += bsp.h + + +BSPFILE = bsp.pri + + +LIBS+= -lgpio -luart -li2c -lspi + +INCLUDEPATH += $${PWD} + +SOURCES += bsp.c +contains(CONFIG , USB){ +SOURCES += usbd_usr.c \ + usbd_desc.c \ + usbd_cdc_vcp.c \ + usb_bsp.c +} + +HEADERS += $$libuc2/bsp/includes/$$BSP/bsp.h \ + usbd_desc.h \ + usbd_conf.h \ + usbd_cdc_vcp.h \ + usb_conf.h diff --git a/bsp/src/stm32f4/M4StickV2/bsp.c b/bsp/src/stm32f4/M4StickV2/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/bsp.c @@ -0,0 +1,143 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + +float VREF0 =(float)3.3; + +int bsp_init() +{ + int i=0; + for(i=0;i<32;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + bsp_spi_init(); + printf("\r================================================================\n\r"); + printf("================================================================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf("================================================================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t GPIOList[]={LED1,LED2,LED3,ADC_MODE0,ADC_MODE1,ADC_FSYNC + ,ADC_SYNC,ADC_CLKDIV}; + gpio_t GPIOx; + for(int i=0;i<8;i++) + { + GPIOx = gpioopen(GPIOList[i]); + gpiosetspeed(&GPIOx,gpiohighspeed); + gpiosetdir(&GPIOx,gpiooutdir); + gpiosetouttype(&GPIOx,gpiopushpulltype); + } + gpioset(ADC_CLKDIV); + gpioset(ADC_MODE0); + gpioset(ADC_MODE1); + gpioclr(ADC_SYNC); + gpioclr(ADC_FSYNC); + delay_100us(10); + gpioset(ADC_SYNC); + +} + +void bsp_uart_init() +{ + if(__opnfiles__[1]==NULL) + { + //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + //uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,230400,PA9,PA10,-1,-1); + uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); + uartmkstreamdev(uart,fd1); + __opnfiles__[1] = fd1; + } + else + { + // uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,230400,PA9,PA10,-1,-1); + uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); + } +} + +void bsp_spi_init() +{ + spiopenandconfig(spi1,spi8bits | spimaster |spiclkinhlow | spiclkfirstedge | spimsbfirst,4000000,DAC_DIN,ADC_DOUT1,ADC_SCLK,-1); +} + + +void bsp_iic_init() +{ + +} + +void bsp_SD_init() +{ + +} + +void vs10XXclearXCS(){} +void vs10XXsetXCS(){} +int vs10XXDREQ() +{ + return 1; +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return 0; +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + + + + + diff --git a/bsp/src/stm32f4/M4StickV2/bsp.h b/bsp/src/stm32f4/M4StickV2/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/bsp.h @@ -0,0 +1,92 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +#include +#include + + +#define __MAX_OPENED_FILES__ 32 +#define __FS_ROOT_SIZE__ 32 + +#define LED1 PD9 +#define LED2 PD8 +#define LED3 PB15 + +#define DAC_CS PA1 +#define DAC_DIN PA7 + +#define ADC_MODE0 PA2 +#define ADC_MODE1 PA3 +#define ADC_FSYNC PA4 +#define ADC_SCLK PA5 +#define ADC_DOUT1 PA6 + +#define ADC_SYNC PB10 +#define ADC_CLKDIV PB11 + + +extern float VREF0; + +extern uint32_t currentCpuFreq; + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); + +/* VS1053 */ +extern void clearXCS(); +extern void setXCS(); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/M4StickV2/bsp.pri b/bsp/src/stm32f4/M4StickV2/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/bsp.pri @@ -0,0 +1,7 @@ +CPU=stm32f4xxxG +DEFINES+=BSP=\\\"M4StickV2\\\" +#CONFIG += USB +USB += cdc +DEFINES+= USE_USB_OTG_FS +DEFINES+=stm32f4 +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/M4StickV2/usb_bsp.c b/bsp/src/stm32f4/M4StickV2/usb_bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/usb_bsp.c @@ -0,0 +1,320 @@ +/** + ****************************************************************************** + * @file usb_bsp.c + * @author MCD Application Team + * @version V1.1.0 + * @date 19-March-2012 + * @brief This file is responsible to offer board support package and is + * configurable by user. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "usb_bsp.h" +#include "usbd_conf.h" + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY +* @{ +*/ + +/** @defgroup USB_BSP +* @brief This file is responsible to offer board support package +* @{ +*/ + +/** @defgroup USB_BSP_Private_Defines +* @{ +*/ +/** +* @} +*/ + + +/** @defgroup USB_BSP_Private_TypesDefinitions +* @{ +*/ +/** +* @} +*/ + + + + + +/** @defgroup USB_BSP_Private_Macros +* @{ +*/ +/** +* @} +*/ + +/** @defgroup USBH_BSP_Private_Variables +* @{ +*/ + +/** +* @} +*/ + +/** @defgroup USBH_BSP_Private_FunctionPrototypes +* @{ +*/ +/** +* @} +*/ + +/** @defgroup USB_BSP_Private_Functions +* @{ +*/ + + +/** +* @brief USB_OTG_BSP_Init +* Initilizes BSP configurations +* @param None +* @retval None +*/ + +void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev) +{ +#ifdef USE_STM3210C_EVAL + + RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3); + RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ; + +#else // USE_STM322xG_EVAL + GPIO_InitTypeDef GPIO_InitStructure; + #ifdef USE_USB_OTG_FS + RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA , ENABLE); + + /* Configure SOF ID DM DP Pins */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | + GPIO_Pin_11 | + GPIO_Pin_12; + + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; + GPIO_Init(GPIOA, &GPIO_InitStructure); + + GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_OTG1_FS) ; + GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_OTG1_FS) ; + GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_OTG1_FS) ; + + /* Configure VBUS Pin */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; + GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; + GPIO_Init(GPIOA, &GPIO_InitStructure); + + /* Configure ID pin */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; + GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_Init(GPIOA, &GPIO_InitStructure); + GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_OTG1_FS) ; + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); + RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ; + #else // USE_USB_OTG_HS + + #ifdef USE_ULPI_PHY // ULPI + RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | + RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOH | + RCC_AHB1Periph_GPIOI, ENABLE); + + + GPIO_PinAFConfig(GPIOA,GPIO_PinSource3, GPIO_AF_OTG2_HS) ; // D0 + GPIO_PinAFConfig(GPIOA,GPIO_PinSource5, GPIO_AF_OTG2_HS) ; // CLK + GPIO_PinAFConfig(GPIOB,GPIO_PinSource0, GPIO_AF_OTG2_HS) ; // D1 + GPIO_PinAFConfig(GPIOB,GPIO_PinSource1, GPIO_AF_OTG2_HS) ; // D2 + GPIO_PinAFConfig(GPIOB,GPIO_PinSource5, GPIO_AF_OTG2_HS) ; // D7 + GPIO_PinAFConfig(GPIOB,GPIO_PinSource10,GPIO_AF_OTG2_HS) ; // D3 + GPIO_PinAFConfig(GPIOB,GPIO_PinSource11,GPIO_AF_OTG2_HS) ; // D4 + GPIO_PinAFConfig(GPIOB,GPIO_PinSource12,GPIO_AF_OTG2_HS) ; // D5 + GPIO_PinAFConfig(GPIOB,GPIO_PinSource13,GPIO_AF_OTG2_HS) ; // D6 + GPIO_PinAFConfig(GPIOH,GPIO_PinSource4, GPIO_AF_OTG2_HS) ; // NXT + GPIO_PinAFConfig(GPIOI,GPIO_PinSource11,GPIO_AF_OTG2_HS) ; // DIR + GPIO_PinAFConfig(GPIOC,GPIO_PinSource0, GPIO_AF_OTG2_HS) ; // STP + + // CLK + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 ; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_Init(GPIOA, &GPIO_InitStructure); + + // D0 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 ; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; + GPIO_Init(GPIOA, &GPIO_InitStructure); + + + + // D1 D2 D3 D4 D5 D6 D7 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | + GPIO_Pin_5 | GPIO_Pin_10 | + GPIO_Pin_11| GPIO_Pin_12 | + GPIO_Pin_13 ; + + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; + GPIO_Init(GPIOB, &GPIO_InitStructure); + + + // STP + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_Init(GPIOC, &GPIO_InitStructure); + + //NXT + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_Init(GPIOH, &GPIO_InitStructure); + + + //DIR + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_Init(GPIOI, &GPIO_InitStructure); + + + RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS | + RCC_AHB1Periph_OTG_HS_ULPI, ENABLE) ; + + #else + + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB , ENABLE); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | + GPIO_Pin_14 | + GPIO_Pin_15; + + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_Init(GPIOB, &GPIO_InitStructure); + + GPIO_PinAFConfig(GPIOB,GPIO_PinSource12, GPIO_AF_OTG2_FS) ; + GPIO_PinAFConfig(GPIOB,GPIO_PinSource14,GPIO_AF_OTG2_FS) ; + GPIO_PinAFConfig(GPIOB,GPIO_PinSource15,GPIO_AF_OTG2_FS) ; + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; + GPIO_Init(GPIOB, &GPIO_InitStructure); + + + RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS, ENABLE) ; + + #endif + #endif //USB_OTG_HS +#endif //USE_STM322xG_EVAL +} +/** +* @brief USB_OTG_BSP_EnableInterrupt +* Enabele USB Global interrupt +* @param None +* @retval None +*/ +void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev) +{ + NVIC_InitTypeDef NVIC_InitStructure; + + NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); +#ifdef USE_USB_OTG_HS + NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_IRQn; +#else + NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; +#endif + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); +#ifdef USB_OTG_HS_DEDICATED_EP1_ENABLED + NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); + NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_EP1_OUT_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); + NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_EP1_IN_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); +#endif +} +/** +* @brief USB_OTG_BSP_uDelay +* This function provides delay time in micro sec +* @param usec : Value of delay required in micro sec +* @retval None +*/ +void USB_OTG_BSP_uDelay (const uint32_t usec) +{ + uint32_t count = 0; + const uint32_t utime = (120 * usec / 7); + do + { + if ( ++count > utime ) + { + return ; + } + } + while (1); +} + + +/** +* @brief USB_OTG_BSP_mDelay +* This function provides delay time in milli sec +* @param msec : Value of delay required in milli sec +* @retval None +*/ +void USB_OTG_BSP_mDelay (const uint32_t msec) +{ + USB_OTG_BSP_uDelay(msec * 1000); +} +/** +* @} +*/ + +/** +* @} +*/ + +/** +* @} +*/ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/src/stm32f4/M4StickV2/usb_conf.h b/bsp/src/stm32f4/M4StickV2/usb_conf.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/usb_conf.h @@ -0,0 +1,310 @@ +/** + ****************************************************************************** + * @file usb_conf.h + * @author MCD Application Team + * @version V1.1.0 + * @date 19-March-2012 + * @brief General low level driver configuration + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USB_CONF__H__ +#define __USB_CONF__H__ + +/* Includes ------------------------------------------------------------------*/ +#if defined (USE_STM322xG_EVAL) + #include "stm322xg_eval.h" + #include "stm322xg_eval_lcd.h" + #include "stm322xg_eval_ioe.h" + #include "stm322xg_eval_sdio_sd.h" +#elif defined(USE_STM324xG_EVAL) + #include "stm32f4xx.h" + #include "stm324xg_eval.h" + #include "stm324xg_eval_lcd.h" + #include "stm324xg_eval_ioe.h" + #include "stm324xg_eval_sdio_sd.h" +#elif defined (USE_STM3210C_EVAL) + #include "stm32f10x.h" + #include "stm3210c_eval.h" + #include "stm3210c_eval_lcd.h" + #include "stm3210c_eval_ioe.h" + #include "stm3210c_eval_spi_sd.h" +#elif defined (stm32f4) + #include "stm32f4xx.h" +#else + #error "Missing define: Evaluation board (ie. USE_STM322xG_EVAL)" +#endif + + +/** @addtogroup USB_OTG_DRIVER + * @{ + */ + +/** @defgroup USB_CONF + * @brief USB low level driver configuration file + * @{ + */ + +/** @defgroup USB_CONF_Exported_Defines + * @{ + */ + +/* USB Core and PHY interface configuration. + Tip: To avoid modifying these defines each time you need to change the USB + configuration, you can declare the needed define in your toolchain + compiler preprocessor. + */ +/****************** USB OTG FS PHY CONFIGURATION ******************************* +* The USB OTG FS Core supports one on-chip Full Speed PHY. +* +* The USE_EMBEDDED_PHY symbol is defined in the project compiler preprocessor +* when FS core is used. +*******************************************************************************/ +#ifndef USE_USB_OTG_FS + //#define USE_USB_OTG_FS +#endif /* USE_USB_OTG_FS */ + +#ifdef USE_USB_OTG_FS + #define USB_OTG_FS_CORE +#endif + +/****************** USB OTG HS PHY CONFIGURATION ******************************* +* The USB OTG HS Core supports two PHY interfaces: +* (i) An ULPI interface for the external High Speed PHY: the USB HS Core will +* operate in High speed mode +* (ii) An on-chip Full Speed PHY: the USB HS Core will operate in Full speed mode +* +* You can select the PHY to be used using one of these two defines: +* (i) USE_ULPI_PHY: if the USB OTG HS Core is to be used in High speed mode +* (ii) USE_EMBEDDED_PHY: if the USB OTG HS Core is to be used in Full speed mode +* +* Notes: +* - The USE_ULPI_PHY symbol is defined in the project compiler preprocessor as +* default PHY when HS core is used. +* - On STM322xG-EVAL and STM324xG-EVAL boards, only configuration(i) is available. +* Configuration (ii) need a different hardware, for more details refer to your +* STM32 device datasheet. +*******************************************************************************/ +#ifndef USE_USB_OTG_HS + //#define USE_USB_OTG_HS +#endif /* USE_USB_OTG_HS */ + +#ifndef USE_ULPI_PHY + //#define USE_ULPI_PHY +#endif /* USE_ULPI_PHY */ + +#ifndef USE_EMBEDDED_PHY + //#define USE_EMBEDDED_PHY +#endif /* USE_EMBEDDED_PHY */ + +#ifdef USE_USB_OTG_HS + #define USB_OTG_HS_CORE +#endif + +/******************************************************************************* +* FIFO Size Configuration in Device mode +* +* (i) Receive data FIFO size = RAM for setup packets + +* OUT endpoint control information + +* data OUT packets + miscellaneous +* Space = ONE 32-bits words +* --> RAM for setup packets = 10 spaces +* (n is the nbr of CTRL EPs the device core supports) +* --> OUT EP CTRL info = 1 space +* (one space for status information written to the FIFO along with each +* received packet) +* --> data OUT packets = (Largest Packet Size / 4) + 1 spaces +* (MINIMUM to receive packets) +* --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces +* (if high-bandwidth EP is enabled or multiple isochronous EPs) +* --> miscellaneous = 1 space per OUT EP +* (one space for transfer complete status information also pushed to the +* FIFO with each endpoint's last packet) +* +* (ii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for +* that particular IN EP. More space allocated in the IN EP Tx FIFO results +* in a better performance on the USB and can hide latencies on the AHB. +* +* (iii) TXn min size = 16 words. (n : Transmit FIFO index) +* (iv) When a TxFIFO is not used, the Configuration should be as follows: +* case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) +* --> Txm can use the space allocated for Txn. +* case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) +* --> Txn should be configured with the minimum space of 16 words +* (v) The FIFO is used optimally when used TxFIFOs are allocated in the top +* of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. +* (vi) In HS case 12 FIFO locations should be reserved for internal DMA registers +* so total FIFO size should be 1012 Only instead of 1024 +*******************************************************************************/ + +/****************** USB OTG HS CONFIGURATION **********************************/ +#ifdef USB_OTG_HS_CORE + #define RX_FIFO_HS_SIZE 512 + #define TX0_FIFO_HS_SIZE 64 + #define TX1_FIFO_HS_SIZE 372 + #define TX2_FIFO_HS_SIZE 64 + #define TX3_FIFO_HS_SIZE 0 + #define TX4_FIFO_HS_SIZE 0 + #define TX5_FIFO_HS_SIZE 0 + +// #define USB_OTG_HS_SOF_OUTPUT_ENABLED + + #ifdef USE_ULPI_PHY + #define USB_OTG_ULPI_PHY_ENABLED + #endif + #ifdef USE_EMBEDDED_PHY + #define USB_OTG_EMBEDDED_PHY_ENABLED + /* wakeup is working only when HS core is configured in FS mode */ + #define USB_OTG_HS_LOW_PWR_MGMT_SUPPORT + #endif + /* #define USB_OTG_HS_INTERNAL_DMA_ENABLED */ /* Be aware that enabling DMA mode will result in data being sent only by + multiple of 4 packet sizes. This is due to the fact that USB DMA does + not allow sending data from non word-aligned addresses. + For this specific application, it is advised to not enable this option + unless required. */ + #define USB_OTG_HS_DEDICATED_EP1_ENABLED +#endif + +/****************** USB OTG FS CONFIGURATION **********************************/ +#ifdef USB_OTG_FS_CORE + #define RX_FIFO_FS_SIZE 128 + #define TX0_FIFO_FS_SIZE 32 + #define TX1_FIFO_FS_SIZE 128 + #define TX2_FIFO_FS_SIZE 32 + #define TX3_FIFO_FS_SIZE 0 + +// #define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT +// #define USB_OTG_FS_SOF_OUTPUT_ENABLED +#endif + +/****************** USB OTG MISC CONFIGURATION ********************************/ +#define VBUS_SENSING_ENABLED + +/****************** USB OTG MODE CONFIGURATION ********************************/ +//#define USE_HOST_MODE +#define USE_DEVICE_MODE +//#define USE_OTG_MODE + +#ifndef USB_OTG_FS_CORE + #ifndef USB_OTG_HS_CORE + #error "USB_OTG_HS_CORE or USB_OTG_FS_CORE should be defined" + #endif +#endif + +#ifndef USE_DEVICE_MODE + #ifndef USE_HOST_MODE + #error "USE_DEVICE_MODE or USE_HOST_MODE should be defined" + #endif +#endif + +#ifndef USE_USB_OTG_HS + #ifndef USE_USB_OTG_FS + #error "USE_USB_OTG_HS or USE_USB_OTG_FS should be defined" + #endif +#else //USE_USB_OTG_HS + #ifndef USE_ULPI_PHY + #ifndef USE_EMBEDDED_PHY + #error "USE_ULPI_PHY or USE_EMBEDDED_PHY should be defined" + #endif + #endif +#endif + +/****************** C Compilers dependant keywords ****************************/ +/* In HS mode and when the DMA is used, all variables and data structures dealing + with the DMA during the transaction process should be 4-bytes aligned */ +#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED + #if defined (__GNUC__) /* GNU Compiler */ + #define __ALIGN_END __attribute__ ((aligned (4))) + #define __ALIGN_BEGIN + #else + #define __ALIGN_END + #if defined (__CC_ARM) /* ARM Compiler */ + #define __ALIGN_BEGIN __align(4) + #elif defined (__ICCARM__) /* IAR Compiler */ + #define __ALIGN_BEGIN + #elif defined (__TASKING__) /* TASKING Compiler */ + #define __ALIGN_BEGIN __align(4) + #endif /* __CC_ARM */ + #endif /* __GNUC__ */ +#else + #define __ALIGN_BEGIN + #define __ALIGN_END +#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ + +/* __packed keyword used to decrease the data type alignment to 1-byte */ +#if defined (__CC_ARM) /* ARM Compiler */ + #define __packed __packed +#elif defined (__ICCARM__) /* IAR Compiler */ + #define __packed __packed +#elif defined ( __GNUC__ ) /* GNU Compiler */ + #define __packed __attribute__ ((__packed__)) +#elif defined (__TASKING__) /* TASKING Compiler */ + #define __packed __unaligned +#endif /* __CC_ARM */ + +/** + * @} + */ + + +/** @defgroup USB_CONF_Exported_Types + * @{ + */ +/** + * @} + */ + + +/** @defgroup USB_CONF_Exported_Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup USB_CONF_Exported_Variables + * @{ + */ +/** + * @} + */ + +/** @defgroup USB_CONF_Exported_FunctionsPrototype + * @{ + */ +/** + * @} + */ + + +#endif //__USB_CONF__H__ + + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/bsp/src/stm32f4/M4StickV2/usbd_cdc_vcp.c b/bsp/src/stm32f4/M4StickV2/usbd_cdc_vcp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/usbd_cdc_vcp.c @@ -0,0 +1,381 @@ +/** + ****************************************************************************** + * @file usbd_cdc_vcp.c + * @author MCD Application Team + * @version V1.1.0 + * @date 19-March-2012 + * @brief Generic media access Layer. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED +#pragma data_alignment = 4 +#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_cdc_vcp.h" +#include "usb_conf.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +LINE_CODING linecoding = + { + 115200, /* baud rate*/ + 0x00, /* stop bits-1*/ + 0x00, /* parity - none*/ + 0x08 /* nb. of bits 8*/ + }; + + +USART_InitTypeDef USART_InitStructure; + +/* These are external variables imported from CDC core to be used for IN + transfer management. */ +extern uint8_t APP_Rx_Buffer []; /* Write CDC received data in this buffer. + These data will be sent over USB IN endpoint + in the CDC core functions. */ +extern uint32_t APP_Rx_ptr_in; /* Increment this pointer or roll it back to + start address when writing received data + in the buffer APP_Rx_Buffer. */ + +/* Private function prototypes -----------------------------------------------*/ +static uint16_t VCP_Init (void); +static uint16_t VCP_DeInit (void); +static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len); +static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len); +static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len); + +static uint16_t VCP_COMConfig(uint8_t Conf); + +CDC_IF_Prop_TypeDef VCP_fops = +{ + VCP_Init, + VCP_DeInit, + VCP_Ctrl, + VCP_DataTx, + VCP_DataRx +}; + +/* Private functions ---------------------------------------------------------*/ +/** + * @brief VCP_Init + * Initializes the Media on the STM32 + * @param None + * @retval Result of the opeartion (USBD_OK in all cases) + */ +static uint16_t VCP_Init(void) +{ + NVIC_InitTypeDef NVIC_InitStructure; + + /* EVAL_COM1 default configuration */ + /* EVAL_COM1 configured as follow: + - BaudRate = 115200 baud + - Word Length = 8 Bits + - One Stop Bit + - Parity Odd + - Hardware flow control disabled + - Receive and transmit enabled + */ + USART_InitStructure.USART_BaudRate = 115200; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; + USART_InitStructure.USART_StopBits = USART_StopBits_1; + USART_InitStructure.USART_Parity = USART_Parity_Odd; + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; + + /* Configure and enable the USART */ + STM_EVAL_COMInit(COM1, &USART_InitStructure); + + /* Enable the USART Receive interrupt */ + USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); + + /* Enable USART Interrupt */ + NVIC_InitStructure.NVIC_IRQChannel = EVAL_COM1_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + return USBD_OK; +} + +/** + * @brief VCP_DeInit + * DeInitializes the Media on the STM32 + * @param None + * @retval Result of the opeartion (USBD_OK in all cases) + */ +static uint16_t VCP_DeInit(void) +{ + + return USBD_OK; +} + + +/** + * @brief VCP_Ctrl + * Manage the CDC class requests + * @param Cmd: Command code + * @param Buf: Buffer containing command data (request parameters) + * @param Len: Number of data to be sent (in bytes) + * @retval Result of the opeartion (USBD_OK in all cases) + */ +static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len) +{ + switch (Cmd) + { + case SEND_ENCAPSULATED_COMMAND: + /* Not needed for this driver */ + break; + + case GET_ENCAPSULATED_RESPONSE: + /* Not needed for this driver */ + break; + + case SET_COMM_FEATURE: + /* Not needed for this driver */ + break; + + case GET_COMM_FEATURE: + /* Not needed for this driver */ + break; + + case CLEAR_COMM_FEATURE: + /* Not needed for this driver */ + break; + + case SET_LINE_CODING: + linecoding.bitrate = (uint32_t)(Buf[0] | (Buf[1] << 8) | (Buf[2] << 16) | (Buf[3] << 24)); + linecoding.format = Buf[4]; + linecoding.paritytype = Buf[5]; + linecoding.datatype = Buf[6]; + /* Set the new configuration */ + VCP_COMConfig(OTHER_CONFIG); + break; + + case GET_LINE_CODING: + Buf[0] = (uint8_t)(linecoding.bitrate); + Buf[1] = (uint8_t)(linecoding.bitrate >> 8); + Buf[2] = (uint8_t)(linecoding.bitrate >> 16); + Buf[3] = (uint8_t)(linecoding.bitrate >> 24); + Buf[4] = linecoding.format; + Buf[5] = linecoding.paritytype; + Buf[6] = linecoding.datatype; + break; + + case SET_CONTROL_LINE_STATE: + /* Not needed for this driver */ + break; + + case SEND_BREAK: + /* Not needed for this driver */ + break; + + default: + break; + } + + return USBD_OK; +} + +/** + * @brief VCP_DataTx + * CDC received data to be send over USB IN endpoint are managed in + * this function. + * @param Buf: Buffer of data to be sent + * @param Len: Number of data to be sent (in bytes) + * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL + */ +static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len) +{ + if (linecoding.datatype == 7) + { + APP_Rx_Buffer[APP_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1) & 0x7F; + } + else if (linecoding.datatype == 8) + { + APP_Rx_Buffer[APP_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1); + } + + APP_Rx_ptr_in++; + + /* To avoid buffer overflow */ + if(APP_Rx_ptr_in == APP_RX_DATA_SIZE) + { + APP_Rx_ptr_in = 0; + } + + return USBD_OK; +} + +/** + * @brief VCP_DataRx + * Data received over USB OUT endpoint are sent over CDC interface + * through this function. + * + * @note + * This function will block any OUT packet reception on USB endpoint + * untill exiting this function. If you exit this function before transfer + * is complete on CDC interface (ie. using DMA controller) it will result + * in receiving more data while previous ones are still not sent. + * + * @param Buf: Buffer of data to be received + * @param Len: Number of data received (in bytes) + * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL + */ +static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len) +{ + uint32_t i; + + for (i = 0; i < Len; i++) + { + USART_SendData(EVAL_COM1, *(Buf + i) ); + while(USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TXE) == RESET); + } + + return USBD_OK; +} + +/** + * @brief VCP_COMConfig + * Configure the COM Port with default values or values received from host. + * @param Conf: can be DEFAULT_CONFIG to set the default configuration or OTHER_CONFIG + * to set a configuration received from the host. + * @retval None. + */ +static uint16_t VCP_COMConfig(uint8_t Conf) +{ + if (Conf == DEFAULT_CONFIG) + { + /* EVAL_COM1 default configuration */ + /* EVAL_COM1 configured as follow: + - BaudRate = 115200 baud + - Word Length = 8 Bits + - One Stop Bit + - Parity Odd + - Hardware flow control disabled + - Receive and transmit enabled + */ + USART_InitStructure.USART_BaudRate = 115200; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; + USART_InitStructure.USART_StopBits = USART_StopBits_1; + USART_InitStructure.USART_Parity = USART_Parity_Odd; + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; + + /* Configure and enable the USART */ + STM_EVAL_COMInit(COM1, &USART_InitStructure); + + /* Enable the USART Receive interrupt */ + USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); + } + else + { + /* set the Stop bit*/ + switch (linecoding.format) + { + case 0: + USART_InitStructure.USART_StopBits = USART_StopBits_1; + break; + case 1: + USART_InitStructure.USART_StopBits = USART_StopBits_1_5; + break; + case 2: + USART_InitStructure.USART_StopBits = USART_StopBits_2; + break; + default : + VCP_COMConfig(DEFAULT_CONFIG); + return (USBD_FAIL); + } + + /* set the parity bit*/ + switch (linecoding.paritytype) + { + case 0: + USART_InitStructure.USART_Parity = USART_Parity_No; + break; + case 1: + USART_InitStructure.USART_Parity = USART_Parity_Even; + break; + case 2: + USART_InitStructure.USART_Parity = USART_Parity_Odd; + break; + default : + VCP_COMConfig(DEFAULT_CONFIG); + return (USBD_FAIL); + } + + /*set the data type : only 8bits and 9bits is supported */ + switch (linecoding.datatype) + { + case 0x07: + /* With this configuration a parity (Even or Odd) should be set */ + USART_InitStructure.USART_WordLength = USART_WordLength_8b; + break; + case 0x08: + if (USART_InitStructure.USART_Parity == USART_Parity_No) + { + USART_InitStructure.USART_WordLength = USART_WordLength_8b; + } + else + { + USART_InitStructure.USART_WordLength = USART_WordLength_9b; + } + + break; + default : + VCP_COMConfig(DEFAULT_CONFIG); + return (USBD_FAIL); + } + + USART_InitStructure.USART_BaudRate = linecoding.bitrate; + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; + + /* Configure and enable the USART */ + STM_EVAL_COMInit(COM1, &USART_InitStructure); + } + return USBD_OK; +} + +/** + * @brief EVAL_COM_IRQHandler + * + * @param None. + * @retval None. + */ +void EVAL_COM_IRQHandler(void) +{ + if (USART_GetITStatus(EVAL_COM1, USART_IT_RXNE) != RESET) + { + /* Send the received data to the PC Host*/ + VCP_DataTx (0,0); + } + + /* If overrun condition occurs, clear the ORE flag and recover communication */ + if (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_ORE) != RESET) + { + (void)USART_ReceiveData(EVAL_COM1); + } +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/src/stm32f4/M4StickV2/usbd_cdc_vcp.h b/bsp/src/stm32f4/M4StickV2/usbd_cdc_vcp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/usbd_cdc_vcp.h @@ -0,0 +1,74 @@ +/** + ****************************************************************************** + * @file usbd_cdc_vcp.h + * @author MCD Application Team + * @version V1.1.0 + * @date 19-March-2012 + * @brief Header for usbd_cdc_vcp.c file. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CDC_VCP_H +#define __USBD_CDC_VCP_H + +/* Includes ------------------------------------------------------------------*/ +#ifdef STM32F2XX + #include "stm32f2xx.h" +#elif defined(STM32F10X_CL) + #include "stm32f10x.h" +#endif /* STM32F2XX */ + +#include "usbd_cdc_core.h" +#include "usbd_conf.h" + + +/* Exported typef ------------------------------------------------------------*/ +/* The following structures groups all needed parameters to be configured for the + ComPort. These parameters can modified on the fly by the host through CDC class + command class requests. */ +typedef struct +{ + uint32_t bitrate; + uint8_t format; + uint8_t paritytype; + uint8_t datatype; +}LINE_CODING; + +/* Exported constants --------------------------------------------------------*/ +/* The following define is used to route the USART IRQ handler to be used. + The IRQ handler function is implemented in the usbd_cdc_vcp.c file. */ + +#ifdef USE_STM3210C_EVAL + #define EVAL_COM_IRQHandler USART2_IRQHandler +#else + #define EVAL_COM_IRQHandler USART3_IRQHandler +#endif /* USE_STM322xG_EVAL */ + + +#define DEFAULT_CONFIG 0 +#define OTHER_CONFIG 1 + +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +#endif /* __USBD_CDC_VCP_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/src/stm32f4/M4StickV2/usbd_conf.h b/bsp/src/stm32f4/M4StickV2/usbd_conf.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/usbd_conf.h @@ -0,0 +1,107 @@ +/** + ****************************************************************************** + * @file usbd_conf.h + * @author MCD Application Team + * @version V1.1.0 + * @date 19-March-2012 + * @brief USB Device configuration file + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CONF__H__ +#define __USBD_CONF__H__ + +/* Includes ------------------------------------------------------------------*/ +#include "usb_conf.h" + +/** @defgroup USB_CONF_Exported_Defines + * @{ + */ +#define USBD_CFG_MAX_NUM 1 +#define USBD_ITF_MAX_NUM 1 + +#define USBD_SELF_POWERED + +#define USB_MAX_STR_DESC_SIZ 255 + +/** @defgroup USB_VCP_Class_Layer_Parameter + * @{ + */ +#define CDC_IN_EP 0x81 /* EP1 for data IN */ +#define CDC_OUT_EP 0x01 /* EP1 for data OUT */ +#define CDC_CMD_EP 0x82 /* EP2 for CDC commands */ + +/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ +#ifdef USE_USB_OTG_HS + #define CDC_DATA_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */ + #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ + + #define CDC_IN_FRAME_INTERVAL 40 /* Number of micro-frames between IN transfers */ + #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer: + APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL*8 */ +#else + #define CDC_DATA_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */ + #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ + + #define CDC_IN_FRAME_INTERVAL 5 /* Number of frames between IN transfers */ + #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer: + APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL */ +#endif /* USE_USB_OTG_HS */ + +#define APP_FOPS VCP_fops +/** + * @} + */ + +/** @defgroup USB_CONF_Exported_Types + * @{ + */ +/** + * @} + */ + + +/** @defgroup USB_CONF_Exported_Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup USB_CONF_Exported_Variables + * @{ + */ +/** + * @} + */ + +/** @defgroup USB_CONF_Exported_FunctionsPrototype + * @{ + */ +/** + * @} + */ + + +#endif //__USBD_CONF__H__ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/bsp/src/stm32f4/M4StickV2/usbd_desc.c b/bsp/src/stm32f4/M4StickV2/usbd_desc.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/usbd_desc.c @@ -0,0 +1,322 @@ +/** + ****************************************************************************** + * @file usbd_desc.c + * @author MCD Application Team + * @version V1.1.0 + * @date 19-March-2012 + * @brief This file provides the USBD descriptors and string formating method. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_req.h" +#include "usbd_conf.h" +#include "usb_regs.h" + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + + +/** @defgroup USBD_DESC + * @brief USBD descriptors module + * @{ + */ + +/** @defgroup USBD_DESC_Private_TypesDefinitions + * @{ + */ +/** + * @} + */ + + +/** @defgroup USBD_DESC_Private_Defines + * @{ + */ +#define USBD_VID 0x0483 + +#define USBD_PID 0x5740 + +/** @defgroup USB_String_Descriptors + * @{ + */ +#define USBD_LANGID_STRING 0x409 +#define USBD_MANUFACTURER_STRING "STMicroelectronics" + +#define USBD_PRODUCT_HS_STRING "STM32 Virtual ComPort in HS mode" +#define USBD_SERIALNUMBER_HS_STRING "00000000050B" + +#define USBD_PRODUCT_FS_STRING "STM32 Virtual ComPort in FS Mode" +#define USBD_SERIALNUMBER_FS_STRING "00000000050C" + +#define USBD_CONFIGURATION_HS_STRING "VCP Config" +#define USBD_INTERFACE_HS_STRING "VCP Interface" + +#define USBD_CONFIGURATION_FS_STRING "VCP Config" +#define USBD_INTERFACE_FS_STRING "VCP Interface" +/** + * @} + */ + + +/** @defgroup USBD_DESC_Private_Macros + * @{ + */ +/** + * @} + */ + + +/** @defgroup USBD_DESC_Private_Variables + * @{ + */ + +USBD_DEVICE USR_desc = +{ + USBD_USR_DeviceDescriptor, + USBD_USR_LangIDStrDescriptor, + USBD_USR_ManufacturerStrDescriptor, + USBD_USR_ProductStrDescriptor, + USBD_USR_SerialStrDescriptor, + USBD_USR_ConfigStrDescriptor, + USBD_USR_InterfaceStrDescriptor, + +}; + +#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED + #if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 + #endif +#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ +/* USB Standard Device Descriptor */ +__ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = + { + 0x12, /*bLength */ + USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ + 0x00, /*bcdUSB */ + 0x02, + 0x00, /*bDeviceClass*/ + 0x00, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID), /*idVendor*/ + HIBYTE(USBD_PID), /*idVendor*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_CFG_MAX_NUM /*bNumConfigurations*/ + } ; /* USB_DeviceDescriptor */ + +#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED + #if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 + #endif +#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ +/* USB Standard Device Descriptor */ +__ALIGN_BEGIN uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = +{ + USB_LEN_DEV_QUALIFIER_DESC, + USB_DESC_TYPE_DEVICE_QUALIFIER, + 0x00, + 0x02, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, +}; + +#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED + #if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 + #endif +#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ +/* USB Standard Device Descriptor */ +__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END = +{ + USB_SIZ_STRING_LANGID, + USB_DESC_TYPE_STRING, + LOBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING), +}; +/** + * @} + */ + + +/** @defgroup USBD_DESC_Private_FunctionPrototypes + * @{ + */ +/** + * @} + */ + + +/** @defgroup USBD_DESC_Private_Functions + * @{ + */ + +/** +* @brief USBD_USR_DeviceDescriptor +* return the device descriptor +* @param speed : current device speed +* @param length : pointer to data length variable +* @retval pointer to descriptor buffer +*/ +uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length) +{ + *length = sizeof(USBD_DeviceDesc); + return USBD_DeviceDesc; +} + +/** +* @brief USBD_USR_LangIDStrDescriptor +* return the LangID string descriptor +* @param speed : current device speed +* @param length : pointer to data length variable +* @retval pointer to descriptor buffer +*/ +uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length) +{ + *length = sizeof(USBD_LangIDDesc); + return USBD_LangIDDesc; +} + + +/** +* @brief USBD_USR_ProductStrDescriptor +* return the product string descriptor +* @param speed : current device speed +* @param length : pointer to data length variable +* @retval pointer to descriptor buffer +*/ +uint8_t * USBD_USR_ProductStrDescriptor( uint8_t speed , uint16_t *length) +{ + + + if(speed == 0) + { + USBD_GetString (USBD_PRODUCT_HS_STRING, USBD_StrDesc, length); + } + else + { + USBD_GetString (USBD_PRODUCT_FS_STRING, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** +* @brief USBD_USR_ManufacturerStrDescriptor +* return the manufacturer string descriptor +* @param speed : current device speed +* @param length : pointer to data length variable +* @retval pointer to descriptor buffer +*/ +uint8_t * USBD_USR_ManufacturerStrDescriptor( uint8_t speed , uint16_t *length) +{ + USBD_GetString (USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** +* @brief USBD_USR_SerialStrDescriptor +* return the serial number string descriptor +* @param speed : current device speed +* @param length : pointer to data length variable +* @retval pointer to descriptor buffer +*/ +uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length) +{ + if(speed == USB_OTG_SPEED_HIGH) + { + USBD_GetString (USBD_SERIALNUMBER_HS_STRING, USBD_StrDesc, length); + } + else + { + USBD_GetString (USBD_SERIALNUMBER_FS_STRING, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** +* @brief USBD_USR_ConfigStrDescriptor +* return the configuration string descriptor +* @param speed : current device speed +* @param length : pointer to data length variable +* @retval pointer to descriptor buffer +*/ +uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length) +{ + if(speed == USB_OTG_SPEED_HIGH) + { + USBD_GetString (USBD_CONFIGURATION_HS_STRING, USBD_StrDesc, length); + } + else + { + USBD_GetString (USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + + +/** +* @brief USBD_USR_InterfaceStrDescriptor +* return the interface string descriptor +* @param speed : current device speed +* @param length : pointer to data length variable +* @retval pointer to descriptor buffer +*/ +uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString (USBD_INTERFACE_HS_STRING, USBD_StrDesc, length); + } + else + { + USBD_GetString (USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @} + */ + + +/** + * @} + */ + + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/bsp/src/stm32f4/M4StickV2/usbd_desc.h b/bsp/src/stm32f4/M4StickV2/usbd_desc.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/usbd_desc.h @@ -0,0 +1,120 @@ +/** + ****************************************************************************** + * @file usbd_desc.h + * @author MCD Application Team + * @version V1.1.0 + * @date 19-March-2012 + * @brief header file for the usbd_desc.c file + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ + +#ifndef __USB_DESC_H +#define __USB_DESC_H + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_def.h" + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @defgroup USB_DESC + * @brief general defines for the usb device library file + * @{ + */ + +/** @defgroup USB_DESC_Exported_Defines + * @{ + */ +#define USB_DEVICE_DESCRIPTOR_TYPE 0x01 +#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 +#define USB_STRING_DESCRIPTOR_TYPE 0x03 +#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 +#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 +#define USB_SIZ_DEVICE_DESC 18 +#define USB_SIZ_STRING_LANGID 4 + +/** + * @} + */ + + +/** @defgroup USBD_DESC_Exported_TypesDefinitions + * @{ + */ +/** + * @} + */ + + + +/** @defgroup USBD_DESC_Exported_Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Variables + * @{ + */ +extern uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC]; +extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ]; +extern uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC]; +extern uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]; +extern uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID]; +extern USBD_DEVICE USR_desc; +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_FunctionsPrototype + * @{ + */ + + +uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_ManufacturerStrDescriptor ( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_ProductStrDescriptor ( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length); + +#ifdef USB_SUPPORT_USER_STRING_DESC +uint8_t * USBD_USR_USRStringDesc (uint8_t speed, uint8_t idx , uint16_t *length); +#endif /* USB_SUPPORT_USER_STRING_DESC */ + +/** + * @} + */ + +#endif /* __USBD_DESC_H */ + +/** + * @} + */ + +/** +* @} +*/ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/src/stm32f4/M4StickV2/usbd_usr.c b/bsp/src/stm32f4/M4StickV2/usbd_usr.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/M4StickV2/usbd_usr.c @@ -0,0 +1,203 @@ +/** + ****************************************************************************** + * @file usbd_usr.c + * @author MCD Application Team + * @version V1.1.0 + * @date 19-March-2012 + * @brief This file includes the user application layer + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_usr.h" +#include "usbd_ioreq.h" +//#include "lcd_log.h" + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY +* @{ +*/ + +/** @defgroup USBD_USR +* @brief This file includes the user application layer +* @{ +*/ + +/** @defgroup USBD_USR_Private_TypesDefinitions +* @{ +*/ +/** +* @} +*/ + + +/** @defgroup USBD_USR_Private_Defines +* @{ +*/ +/** +* @} +*/ + + +/** @defgroup USBD_USR_Private_Macros +* @{ +*/ +/** +* @} +*/ + + +/** @defgroup USBD_USR_Private_Variables +* @{ +*/ + +USBD_Usr_cb_TypeDef USR_cb = +{ + USBD_USR_Init, + USBD_USR_DeviceReset, + USBD_USR_DeviceConfigured, + USBD_USR_DeviceSuspended, + USBD_USR_DeviceResumed, + + + USBD_USR_DeviceConnected, + USBD_USR_DeviceDisconnected, +}; + +/** +* @} +*/ + +/** @defgroup USBD_USR_Private_Constants +* @{ +*/ + +/** +* @} +*/ + + + +/** @defgroup USBD_USR_Private_FunctionPrototypes +* @{ +*/ +/** +* @} +*/ + + +/** @defgroup USBD_USR_Private_Functions +* @{ +*/ + +/** +* @brief USBD_USR_Init +* Displays the message on LCD for host lib initialization +* @param None +* @retval None +*/ +void USBD_USR_Init(void) +{ + /* Initialize LEDs */ + //STM_EVAL_LEDInit(LED1); + //STM_EVAL_LEDInit(LED2); + //STM_EVAL_LEDInit(LED3); + //STM_EVAL_LEDInit(LED4); + +} + +/** +* @brief USBD_USR_DeviceReset +* Displays the message on LCD on device Reset Event +* @param speed : device speed +* @retval None +*/ +void USBD_USR_DeviceReset(uint8_t speed ) +{ + +} + + +/** +* @brief USBD_USR_DeviceConfigured +* Displays the message on LCD on device configuration Event +* @param None +* @retval Staus +*/ +void USBD_USR_DeviceConfigured (void) +{ +} + +/** +* @brief USBD_USR_DeviceSuspended +* Displays the message on LCD on device suspend Event +* @param None +* @retval None +*/ +void USBD_USR_DeviceSuspended(void) +{ + + /* Users can do their application actions here for the USB-Reset */ +} + + +/** +* @brief USBD_USR_DeviceResumed +* Displays the message on LCD on device resume Event +* @param None +* @retval None +*/ +void USBD_USR_DeviceResumed(void) +{ + + /* Users can do their application actions here for the USB-Reset */ +} + + +/** +* @brief USBD_USR_DeviceConnected +* Displays the message on LCD on device connection Event +* @param None +* @retval Staus +*/ +void USBD_USR_DeviceConnected (void) +{ + +} + + +/** +* @brief USBD_USR_DeviceDisonnected +* Displays the message on LCD on device disconnection Event +* @param None +* @retval Staus +*/ +void USBD_USR_DeviceDisconnected (void) +{ + +} +/** +* @} +*/ + +/** +* @} +*/ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/src/stm32f4/OPLAYER/OPLAYER.pro b/bsp/src/stm32f4/OPLAYER/OPLAYER.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/OPLAYER/OPLAYER.pro @@ -0,0 +1,28 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp gui audio fs + +BSP = OPLAYER + +UCMODEL=stm32f4 + +SOURCES += bsp.c \ + bsp_spi.c \ + bsp_lcd.c \ + bsp_sdcard.c \ + bsp_audio.c + +HEADERS += bsp.h \ + ../../common/bsp_spi.h \ + ../../common/bsp_i2c.h \ + ../../common/bsp_gpio.h + +INCLUDEPATH += ../../common/ + +LIBS+= -lgpio -luart -li2c -lspi + +BSPFILE = bsp.pri + + + diff --git a/bsp/src/stm32f4/OPLAYER/bsp.c b/bsp/src/stm32f4/OPLAYER/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/OPLAYER/bsp.c @@ -0,0 +1,204 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "bsp_gpio.h" +#include "bsp_i2c.h" +#include "bsp_i2c.h" + +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + + + +LCD_IF_t lcdIF0={ + .init = &bsp_FSMC_init, + .writereg = &bsp_lcd0_write_reg, + .readreg = &bsp_lcd0_read_reg, + .writeGRAM = &bsp_lcd0_writeGRAM, + .readGRAM = &bsp_lcd0_readGRAM +}; + +LCD_t lcd0={ + .interface = &lcdIF0, + .init = &ili9328init, + .paint = &ili9328paint, + .paintText = &ili9328paintText, + .paintFilRect = &ili9328paintFilRect, + .getPix = &ili9328getPix, + .refreshenable = &ili9328refreshenable, + .width= 240, + .height = 320 +}; + +terminal_t terminal0; + + + +float VREF0 =(float)3.3; +volatile vs10XXDev audioCodec0; + +ADS7843_t TC0; + +sdcardDev sdcard2; +blkdevice sdcard2blkdev; +dikpartition sdcard2Part1; +FAT32fs sdcard2FAT32part1; +dikpartition sdcard2Part2; +FAT32fs sdcard2FAT32part2; +dikpartition sdcard2Part3; +FAT32fs sdcard2FAT32part3; +dikpartition sdcard2Part4; +FAT32fs sdcard2FAT32part4; + +int bsp_init() +{ + int i=0; + for(i=0;i<__MAX_OPENED_FILES__;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + bsp_iic_init(); + bsp_FSMC_init(); + bsp_GTerm_init(); + bsp_spi_init(); + bsp_SD_init(); + bsp_Audio_init(); + bsp_TC_init(); + printf("\r=====================\n\r"); + printf( "=====================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf( "=====================\n\r"); +#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + printf( "BIG ENDIAN MACHINE\n\r"); +#else + printf( "LITLE ENDIAN MACHINE\n\r"); +#endif + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t GPIO_Out_init_List[]={LED1,LED2,LCD_RESET,LCD_BACKL,VS1053xCS,VS1053xDCS,\ + VS1053xRESET,SDCARD2CS,LCD_RS,LCD_CS,TC_CS}; + + gpio_t GPIO_In_init_List[]={VS1053DREQ,SDCARD2CD,BP3,TC_BUSY}; + + bsp_gpio_set_outputs(GPIO_Out_init_List,11); + bsp_gpio_set_inputs(GPIO_In_init_List,4); + + gpioclr(VS1053xRESET); + gpioset(VS1053xCS); + gpioset(VS1053xDCS); + gpioset(SDCARD2CS); + gpioclr(LCD_RESET); + gpioclr(LCD_BACKL); +} + +void bsp_uart_init() +{ + +} + + + + + +int bsp_TC_init() +{ + ads7843init(&TC0,TC_SPI,tcsetncs,tcbusy); +} + + + + +void bsp_iic_init() +{ + // i2copenandconfig(i2c2,0,10000,PF0,PF1); +} + + + + +void tcsetncs(char val) +{ + if(val) + gpioset(TC_CS); + else + gpioclr(TC_CS); +} + +int tcbusy() +{ + return gpiogetval(TC_BUSY); +} + + + + + +void bsp_GTerm_init() +{ + if(__opnfiles__[1]==NULL) + { + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); + terminal_settextColor(&terminal0,0); + __opnfiles__[1] = fd1; + } + else + { + + } +} + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/OPLAYER/bsp.h b/bsp/src/stm32f4/OPLAYER/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/OPLAYER/bsp.h @@ -0,0 +1,151 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) +#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) + + +#define __MAX_OPENED_FILES__ 4 +#define __FS_ROOT_SIZE__ 4 + + +#define LED1 PC15 +#define LED2 PC14 + +#define BP3 PA0 + +#define LCD_RESET PD10 +#define LCD_BACKL PE11 +#define LCD_RS PE4 +#define LCD_CS PD7 + +#define TC_SPI spi2 +#define TC_PEN PC4 +#define TC_BUSY PC5 +#define TC_CS PB12 +#define TC_CLK PB13 +#define TC_DOUT PB14 +#define TC_DIN PB15 + +#define VS1053SPI spi1 +#define VS1053xCS PA3 +#define VS1053xRESET PA2 +#define VS1053xDCS PA4 +#define VS1053DREQ PA1 +#define VS1053MISO PA6 +#define VS1053MOSI PA7 +#define VS1053SCK PA5 + + + +#define SDCARD2SPI spi3 +#define SDCARD2CS PB8 +#define SDCARD2CD PB9 +#define SDCARD2MISO PB4 +#define SDCARD2MOSI PB5 +#define SDCARD2SCK PB3 + +extern float VREF0; + +extern uint32_t currentCpuFreq; +extern LCD_t lcd0; +extern ADS7843_t TC0; + +extern volatile vs10XXDev audioCodec0; + +extern sdcardDev sdcard2; +extern blkdevice sdcard2blkdev; +extern dikpartition sdcard2Part1; +extern FAT32fs sdcard2FAT32part1; +extern dikpartition sdcard2Part2; +extern FAT32fs sdcard2FAT32part2; +extern dikpartition sdcard2Part3; +extern FAT32fs sdcard2FAT32part3; +extern dikpartition sdcard2Part4; +extern FAT32fs sdcard2FAT32part4; + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); +extern void bsp_Audio_init(); +extern void bsp_GTerm_init(); +extern int bsp_FSMC_init(); +extern int bsp_TC_init(); +extern void tcsetncs(char val); +extern int tcbusy(); +/* VS1053 */ +extern void vs1052setXCS(char val); +extern void vs1052setXDCS(char val); +extern void vs1052setRST(char val); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); +uint32_t bsp_lcd0_read_reg(uint32_t reg); +void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); +void bsp_lcd0_readGRAM(void *buffer, uint32_t count); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/OPLAYER/bsp.pri b/bsp/src/stm32f4/OPLAYER/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/OPLAYER/bsp.pri @@ -0,0 +1,4 @@ +CPU=stm32f4xxxG +DEFINES+=BSP=\\\"OPLAYER\\\" + +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/OPLAYER/bsp_audio.c b/bsp/src/stm32f4/OPLAYER/bsp_audio.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/OPLAYER/bsp_audio.c @@ -0,0 +1,94 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void bsp_Audio_init() +{ + vs10XXopen(&audioCodec0,VS1053SPI,vs1052setXCS,vs1052setRST,vs1052setXDCS,vs10XXDREQ); + if(audioCodec0.VERSION!=UNKNOWN) + { + printf("detected Audio codec "); + switch (audioCodec0.VERSION) { + case VS1001: + printf("VS1001\n"); + break; + case VS1011: + printf("VS1011\n"); + break; + case VS1002: + printf("VS1002\n"); + break; + case VS1003: + printf("VS1003\n"); + break; + case VS1053: + printf("VS1053\n"); + break; + case VS1033: + printf("VS1033\n"); + break; + case VS1103: + printf("VS1103\n"); + break; + default: + printf("Unknown device\n"); + break; + } + } +} + + + +void vs1052setXCS(char val) +{ + gpiosetval(VS1053xCS,(int)val); +} + +void vs1052setXDCS(char val) +{ + //gpiosetval(LED1,(int)val); + gpiosetval(VS1053xDCS,(int)val); +} + +void vs1052setRST(char val) +{ + if(val) + gpioset(VS1053xRESET); + else + gpioclr(VS1053xRESET); +} + + +int vs10XXDREQ() +{ + return gpiogetval(VS1053DREQ); +} diff --git a/bsp/src/stm32f4/OPLAYER/bsp_lcd.c b/bsp/src/stm32f4/OPLAYER/bsp_lcd.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/OPLAYER/bsp_lcd.c @@ -0,0 +1,266 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define clr_RS gpioclr(LCD_RS) +#define set_RS gpioset(LCD_RS) + +#define clr_CS gpioclr(LCD_CS) +#define set_CS gpioset(LCD_CS) + +volatile int8_t* lcd0_CMD=(volatile int8_t*)0x60000000; +volatile int16_t* lcd0_CMD16=(volatile int16_t*)0x60000000; +volatile int8_t* lcd0_DATA=(volatile int8_t*)0x61FFFFF0; +volatile int16_t* lcd0_DATA16=(volatile int16_t*)0x61FFFFF0; + +/* +D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 +D5 PE8 D6 PE9 D7 PE10 +A20 PE4 = RS FSMC_NE1 PD7 CS FSMC_NWE PD5 W/S +FSMC_NOE PD4 RD +*/ + +int bsp_FSMC_init() +{ + + gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10\ + ,PD4,PD5}; +// gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10\ +// ,PD4,PD5,PD7,PE4}; + for(int i=0;i<10;i++) + { + gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); + LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; + gpiosetconfig(&LCD_DBx); + GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); + } + + FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; + FSMC_NORSRAMTimingInitTypeDef p; + + /* Enable FSMC clock */ + RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); + + /*-- FSMC Configuration ------------------------------------------------------*/ + /*----------------------- SRAM Bank 3 ----------------------------------------*/ + /* FSMC_Bank1_NORSRAM4 configuration */ + p.FSMC_AddressSetupTime = 1;//3 + p.FSMC_AddressHoldTime = 1;//3 + //ili9328 -> data setup time > 10ns + p.FSMC_DataSetupTime = 6; + p.FSMC_CLKDivision = 3; + if(getCpuFreq()>=100*1000*1000) + { + p.FSMC_CLKDivision = 3; + p.FSMC_DataSetupTime = 6;// 11; + } + p.FSMC_BusTurnAroundDuration = 0; + p.FSMC_DataLatency = 3; + //ili9328 -> data hold time > 15ns + if(getCpuFreq()>66*1000*1000) + p.FSMC_DataLatency = 3; + p.FSMC_AccessMode = FSMC_AccessMode_D; + + + FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; + FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; + FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR; + FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; + FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; + FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; + FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; + FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; //Dis + FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; + FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; + FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; + + FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); + + FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); + gpioset(LCD_RESET); + gpioclr(LCD_RESET); + delay_100us(500); + gpioset(LCD_RESET); + delay_100us(500); + lcd0.init(&lcd0); + gpioset(LCD_BACKL); + return 1; +} + + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) +{ + uint8_t* pt8 = (uint8_t*)(void*)(®); +#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + *lcd0_CMD=pt8[3]; + *lcd0_CMD=pt8[2]; + pt8 = (uint8_t*)(void*)&data; + *lcd0_DATA=pt8[3]; + *lcd0_DATA=pt8[2]; +#else + clr_CS; + clr_RS; + *lcd0_CMD=pt8[1]; + *lcd0_CMD=pt8[0]; + set_RS; + pt8 = (uint8_t*)(void*)&data; + *lcd0_DATA=pt8[1]; + *lcd0_DATA=pt8[0]; + set_CS; +#endif + +} + +uint32_t bsp_lcd0_read_reg(uint32_t reg) +{ + uint8_t* pt8 = (uint8_t*)(void*)(®); + uint32_t DATA=0; + +#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + *lcd0_CMD=pt8[3]; + *lcd0_CMD=pt8[2]; + pt8 = (uint8_t*)(void*)&DATA; + pt8[3]=*lcd0_DATA; + pt8[2]=*lcd0_DATA; +#else + clr_CS; + clr_RS; + *lcd0_CMD=pt8[1]; + *lcd0_CMD=pt8[0]; + set_RS; + pt8 = (uint8_t*)(void*)&DATA; + pt8[1]=*lcd0_DATA; + pt8[0]=*lcd0_DATA; + set_CS; +#endif + + return DATA; +} + +void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) +{ + uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; + uint8_t* pt8 = (uint8_t*)(void*)(®); +#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + *lcd0_CMD=pt8[3]; + *lcd0_CMD=pt8[2]; + pt8 = (uint8_t*)(void*)buffer; + for(int i=0;i<(int)count;i++) + { + *lcd0_DATA=pt8[(2*i) +1]; + *lcd0_DATA=pt8[2*i]; + } +#else + clr_CS; + clr_RS; + *lcd0_CMD=pt8[1]; + *lcd0_CMD=pt8[0]; + set_RS; + pt8 = (uint8_t*)(void*)buffer; + for(int i=0;i<(int)count;i++) + { + + *lcd0_DATA=pt8[(2*i) +1]; + *lcd0_DATA=pt8[2*i]; + } + set_CS; +#endif +} + + +void bsp_lcd0_readGRAM(void* buffer,uint32_t count) +{ + //uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; + volatile uint8_t* pt8;// = (uint8_t*)(void*)® + /* #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + *lcd0_CMD=pt8[3]; + *lcd0_CMD=pt8[2]; + pt8 = (uint8_t*)(void*)buffer; + for(int i=0;i<(int)count;i++) + { + pt8[(2*i) +1]=*lcd0_DATA; + pt8[2*i]=*lcd0_DATA; + } +#else + *lcd0_CMD=(uint8_t)0; + *lcd0_CMD=(uint8_t)0; + *lcd0_CMD=(uint8_t)0; + *lcd0_CMD=(uint8_t)0; + *lcd0_CMD=pt8[1]; + *lcd0_CMD=pt8[0]; + pt8 = (uint8_t*)buffer;*/ + /* + * x dummy reads Cf ili9328 datasheet p79! + */ + /* pt8[0]=*lcd0_DATA; + pt8[1]=*lcd0_DATA; + + for(int i=0;i<(int)count;i++) + { + pt8[(2*i) +1]=*lcd0_DATA; + pt8[2*i]=*lcd0_DATA; + pt8[(2*i) +1]=*lcd0_DATA; + pt8[2*i]=*lcd0_DATA; + } +#endif*/ + //clr_CS; + //clr_RS; + //*lcd0_CMD=(int8_t)0; + //*lcd0_CMD=(int8_t)0x22; +// *lcd0_CMD=(int8_t)0x00; + //set_RS; + pt8 = (uint8_t*)buffer; + //pt8[1]=*lcd0_DATA; + //pt8[0]=*lcd0_DATA; + pt8[0]=0xFF; + pt8[1]=0xFF; +/* for(int i=0;i<(int)count;i++) + { + pt8[(2*i)+1]= *lcd0_DATA; + pt8[2*i]= *lcd0_DATA; + }*/ + set_CS; +} + + + + + + + + diff --git a/bsp/src/stm32f4/OPLAYER/bsp_sdcard.c b/bsp/src/stm32f4/OPLAYER/bsp_sdcard.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/OPLAYER/bsp_sdcard.c @@ -0,0 +1,116 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +void bsp_SD_init() +{ + if(bspsdcardpresent()) + { + sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed); + sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); + if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT) + { + if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1)) + printf("Can't open fat32 partition 1\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2)) + printf("Can't open fat32 partition 2\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3)) + printf("Can't open fat32 partition 3\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4)) + printf("Can't open fat32 partition 4\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + } + else + { + printf("Can't initialize SDCARD\n"); + } + } +} + + + + + + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return gpiogetval(SDCARD2CD); +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + // gpiosetval(LED1,(int)YESNO); + if(YESNO) + gpioclr(SDCARD2CS); + else + gpioset(SDCARD2CS); +} + diff --git a/bsp/src/stm32f4/OPLAYER/bsp_spi.c b/bsp/src/stm32f4/OPLAYER/bsp_spi.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/OPLAYER/bsp_spi.c @@ -0,0 +1,70 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) +#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) + + +void bsp_spi_init() +{ + gpio_t VSSPI_DBxList[]={VS1053SCK,VS1053MOSI,VS1053MISO}; + for(int i=0;i<3;i++) + { + gpio_t SPI_DBx = gpioopen(VSSPI_DBxList[i]); + SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; + gpiosetconfig(&SPI_DBx); + GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI1); + } + spiopenandconfig(VS1053SPI,spi8bits|spimaster|spimsbfirst,2*1000*1000,VS1053MOSI,VS1053MISO,VS1053SCK,-1); + + gpio_t SDSPI_DBxList[]={SDCARD2SCK,SDCARD2MOSI,SDCARD2MISO}; + for(int i=0;i<3;i++) + { + gpio_t SPI_DBx = gpioopen(SDSPI_DBxList[i]); + SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; + gpiosetconfig(&SPI_DBx); + GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI3); + } + spiopenandconfig(SDCARD2SPI,spi8bits|spimaster|spimsbfirst,400*1000,SDCARD2MOSI,SDCARD2MISO,SDCARD2SCK,-1); + + gpio_t TCSPI_DBxList[]={TC_CLK,TC_DIN,TC_DOUT}; + for(int i=0;i<3;i++) + { + gpio_t SPI_DBx = gpioopen(TCSPI_DBxList[i]); + SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; + gpiosetconfig(&SPI_DBx); + GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI2); + } + spiopenandconfig(TC_SPI,spi8bits|spimaster|spimsbfirst,500*1000,TC_DIN,TC_DOUT,TC_CLK,-1); + +} diff --git a/bsp/src/stm32f4/SOLAR_LFR_PSU/SOLAR_LFR_PSU.pro b/bsp/src/stm32f4/SOLAR_LFR_PSU/SOLAR_LFR_PSU.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/SOLAR_LFR_PSU/SOLAR_LFR_PSU.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp + +BSP=SOLAR_LFR_PSU + +UCMODEL=stm32f4 + +SOURCES += bsp.c + +HEADERS += bsp.h + +LIBS+= -lgpio -luart -li2c -lspi + +BSPFILE = bsp.pri + + + diff --git a/bsp/src/stm32f4/SOLAR_LFR_PSU/bsp.c b/bsp/src/stm32f4/SOLAR_LFR_PSU/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/SOLAR_LFR_PSU/bsp.c @@ -0,0 +1,140 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include + +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + +float VREF0 =(float)3.3; + +int bsp_init() +{ + int i=0; + for(i=0;i<32;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + bsp_iic_init(); + printf("\r================================================================\n\r"); + printf("================================================================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf("================================================================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 + gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); + gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); + gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); + gpio_t dacRst=gpioopen(PD4); + gpiosetspeed(&gpio1,gpiohighspeed); + gpiosetspeed(&gpio2,gpiohighspeed); + gpiosetspeed(&gpio3,gpiohighspeed); + gpiosetspeed(&gpio4,gpiohighspeed); + gpiosetspeed(&dacRst,gpiohighspeed); + gpiosetdir(&gpio1,gpiooutdir); + gpiosetdir(&gpio3,gpiooutdir); + gpiosetdir(&gpio2,gpiooutdir); + gpiosetdir(&gpio4,gpiooutdir); + gpiosetdir(&dacRst,gpiooutdir); + gpioset(dacRst); +} + +void bsp_uart_init() +{ + if(__opnfiles__[1]==NULL) + { + //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); + uartmkstreamdev(uart,fd1); + __opnfiles__[1] = fd1; + } + else + { + uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); + } +} + +void bsp_spi_init() +{ + +} + + +void bsp_iic_init() +{ + i2copenandconfig(i2c1,0,400000,PB9,PB6); + i2copenandconfig(i2c3,0,400000,PC9,PA8); +} + +void bsp_SD_init() +{ + +} + +void vs10XXclearXCS(){} +void vs10XXsetXCS(){} +int vs10XXDREQ() +{ + return 1; +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return 0; +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + + + + + diff --git a/bsp/src/stm32f4/SOLAR_LFR_PSU/bsp.h b/bsp/src/stm32f4/SOLAR_LFR_PSU/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/SOLAR_LFR_PSU/bsp.h @@ -0,0 +1,87 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +#include +#include + +#define __MAX_OPENED_FILES__ 32 +#define __FS_ROOT_SIZE__ 32 +/* +#ifndef PD8 + #define PD8 +#endif +#ifndef PD9 + #define PD9 +#endif +*/ + +#define LED1 PD12 +#define LED2 PD13 +#define LED3 PD14 +#define LED4 PD15 + +extern float VREF0; + +extern uint32_t currentCpuFreq; + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); + +/* VS1053 */ +extern void clearXCS(); +extern void setXCS(); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/SOLAR_LFR_PSU/bsp.pri b/bsp/src/stm32f4/SOLAR_LFR_PSU/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/SOLAR_LFR_PSU/bsp.pri @@ -0,0 +1,3 @@ +CPU=stm32f4xxxG +DEFINES+=BSP=\\\"SOLAR_LFR_PSU\\\" +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/STM32-E407/STM32-E407.pro b/bsp/src/stm32f4/STM32-E407/STM32-E407.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32-E407/STM32-E407.pro @@ -0,0 +1,26 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp + +BSP = STM32-E407 + +UCMODEL=stm32f4 + +SOURCES += bsp.c \ + bsp_spi.c \ + bsp_sdcard.c + +HEADERS += bsp.h \ + ../../common/bsp_spi.h \ + ../../common/bsp_i2c.h \ + ../../common/bsp_gpio.h + +INCLUDEPATH += ../../common/ + +LIBS+= -lgpio -luart -li2c -lspi + +BSPFILE = bsp.pri + + + diff --git a/bsp/src/stm32f4/STM32-E407/bsp.c b/bsp/src/stm32f4/STM32-E407/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32-E407/bsp.c @@ -0,0 +1,139 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "bsp_gpio.h" +#include "bsp_i2c.h" +#include "bsp_i2c.h" + +uint32_t OSC0 =12000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + + +float VREF0 =(float)3.3; + +sdcardDev sdcard2; +blkdevice sdcard2blkdev; +dikpartition sdcard2Part1; +FAT32fs sdcard2FAT32part1; +dikpartition sdcard2Part2; +FAT32fs sdcard2FAT32part2; +dikpartition sdcard2Part3; +FAT32fs sdcard2FAT32part3; +dikpartition sdcard2Part4; +FAT32fs sdcard2FAT32part4; + +int bsp_init() +{ + int i=0; + for(i=0;i<__MAX_OPENED_FILES__;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + bsp_iic_init(); + bsp_spi_init(); + bsp_SD_init(); + printf("\r=====================\n\r"); + printf( "=====================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf( "=====================\n\r"); +#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + printf( "BIG ENDIAN MACHINE\n\r"); +#else + printf( "LITLE ENDIAN MACHINE\n\r"); +#endif + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t GPIO_Out_init_List[]={LED1}; + + gpio_t GPIO_In_init_List[]={BP1}; + + bsp_gpio_set_outputs(GPIO_Out_init_List,1); + bsp_gpio_set_inputs(GPIO_In_init_List,1); + +} + +void bsp_uart_init() +{ + if(__opnfiles__[1]==NULL) + { + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + uart_t uart = uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,115200,PC6,PC7,-1,-1); + uartmkstreamdev(uart,fd1); + __opnfiles__[1] = fd1; + } + else + { + uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,115200,PC6,PC7,-1,-1); + } +} + + + + +void bsp_iic_init() +{ + // i2copenandconfig(i2c2,0,10000,PF0,PF1); +} + + + + +void bsp_GTerm_init() +{ + +} + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/STM32-E407/bsp.h b/bsp/src/stm32f4/STM32-E407/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32-E407/bsp.h @@ -0,0 +1,98 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __MAX_OPENED_FILES__ 4 +#define __FS_ROOT_SIZE__ 4 + + +#define LED1 PC13 +#define LED2 PC13 + +#define BP1 PA0 + + +extern float VREF0; + +extern uint32_t currentCpuFreq; + + +extern sdcardDev sdcard2; +extern blkdevice sdcard2blkdev; +extern dikpartition sdcard2Part1; +extern FAT32fs sdcard2FAT32part1; +extern dikpartition sdcard2Part2; +extern FAT32fs sdcard2FAT32part2; +extern dikpartition sdcard2Part3; +extern FAT32fs sdcard2FAT32part3; +extern dikpartition sdcard2Part4; +extern FAT32fs sdcard2FAT32part4; + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/STM32-E407/bsp.pri b/bsp/src/stm32f4/STM32-E407/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32-E407/bsp.pri @@ -0,0 +1,4 @@ +CPU=stm32f4xxxG +DEFINES+=BSP=\\\"STM32-E407\\\" + +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/STM32-E407/bsp_sdcard.c b/bsp/src/stm32f4/STM32-E407/bsp_sdcard.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32-E407/bsp_sdcard.c @@ -0,0 +1,60 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +void bsp_SD_init() +{ + +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + diff --git a/bsp/src/stm32f4/STM32-E407/bsp_spi.c b/bsp/src/stm32f4/STM32-E407/bsp_spi.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32-E407/bsp_spi.c @@ -0,0 +1,38 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void bsp_spi_init() +{ + + +} diff --git a/bsp/src/stm32f4/STM32F429Discovery/STM32F429Discovery.pro b/bsp/src/stm32f4/STM32F429Discovery/STM32F429Discovery.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F429Discovery/STM32F429Discovery.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp + +BSP=STM32F429Discovery + +UCMODEL=stm32f4 + +SOURCES += bsp.c + +HEADERS += bsp.h + +LIBS+= -lgpio -luart -li2c -lspi + +BSPFILE = bsp.pri + + + diff --git a/bsp/src/stm32f4/STM32F429Discovery/bsp.c b/bsp/src/stm32f4/STM32F429Discovery/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F429Discovery/bsp.c @@ -0,0 +1,131 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + +float VREF0 =(float)3.3; + +int bsp_init() +{ + int i=0; + for(i=0;i<32;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + printf("\r================================================================\n\r"); + printf("================================================================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf("================================================================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t gpio1 = gpioopen(LED1); + gpio_t gpio2 = gpioopen(LED2); + gpio_t gpio3 = gpioopen(BP0); + gpiosetspeed(&gpio1,gpiohighspeed); + gpiosetspeed(&gpio2,gpiohighspeed); + gpiosetspeed(&gpio3,gpiohighspeed); + gpiosetdir(&gpio1,gpiooutdir); + gpiosetdir(&gpio2,gpiooutdir); + gpiosetdir(&gpio3,gpioindir); +} + +void bsp_uart_init() +{ + if(__opnfiles__[1]==NULL) + { + //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); + 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; //stdo + __opnfiles__[0] = fd1; //stdi + } + else + { + uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); + } +} + +void bsp_spi_init() +{ + +} + + +void bsp_iic_init() +{ + +} + +void bsp_SD_init() +{ + +} + + +void vs10XXclearXCS(){} +void vs10XXsetXCS(){} +int vs10XXDREQ() +{ + return 1; +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return 0; +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + + + + + diff --git a/bsp/src/stm32f4/STM32F429Discovery/bsp.h b/bsp/src/stm32f4/STM32F429Discovery/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F429Discovery/bsp.h @@ -0,0 +1,80 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include + +#define __MAX_OPENED_FILES__ 32 +#define __FS_ROOT_SIZE__ 32 + +#define LED1 PG13 +#define LED2 PG14 + +#define BP0 PA0 + +extern float VREF0; + +extern uint32_t OSC0; +extern uint32_t currentCpuFreq; + + + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); + +/* VS1053 */ +extern void clearXCS(); +extern void setXCS(); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/STM32F429Discovery/bsp.pri b/bsp/src/stm32f4/STM32F429Discovery/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F429Discovery/bsp.pri @@ -0,0 +1,3 @@ +CPU=stm32f42x +DEFINES+=BSP=\\\"STM32F429Discovery\\\" +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/STM32F4Discovery-EXT/STM32F4Discovery-EXT.pro b/bsp/src/stm32f4/STM32F4Discovery-EXT/STM32F4Discovery-EXT.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery-EXT/STM32F4Discovery-EXT.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp gui + +BSP=STM32F4Discovery-EXT + +UCMODEL=stm32f4 + +SOURCES += bsp.c + +HEADERS += bsp.h +LIBS+= -lgpio -luart -li2c -lspi + +BSPFILE = bsp.pri + + + diff --git a/bsp/src/stm32f4/STM32F4Discovery-EXT/bsp.c b/bsp/src/stm32f4/STM32F4Discovery-EXT/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery-EXT/bsp.c @@ -0,0 +1,311 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + +float VREF0 =(float)3.3; + +LCD_IF_t lcdIF0={ + .init = &bsp_FSMC_init, + .writereg = &bsp_lcd0_write_reg, + .readreg = &bsp_lcd0_read_reg, + .writeGRAM = &bsp_lcd0_writeGRAM, + .readGRAM = &bsp_lcd0_readGRAM +}; + +LCD_t lcd0={ + .interface = &lcdIF0, + .init = &ssd2119init, + .paint = &ssd2119paint, + .paintText = &ssd2119paintText, + .paintFilRect = &ssd2119paintFilRect, + .refreshenable = &ssd2119refreshenable, + .width= 320, + .height = 240 +}; + + +volatile int16_t* lcd0_CMD=(volatile int16_t*) 0x60000000; +volatile int16_t* lcd0_DATA=(volatile int16_t*)(0x60FFFFF0); + +int bsp_init() +{ + int i=0; + for(i=0;i<32;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + bsp_FSMC_init(); + printf("\r================================================================\n\r"); + printf("================================================================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf("================================================================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 + // gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); + gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); + // gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); + gpiosetspeed(&gpio1,gpiohighspeed); + //gpiosetspeed(&gpio2,gpiohighspeed); + gpiosetspeed(&gpio3,gpiohighspeed); + //gpiosetspeed(&gpio4,gpiohighspeed); + gpiosetdir(&gpio1,gpiooutdir); + gpiosetdir(&gpio3,gpiooutdir); + // gpiosetdir(&gpio2,gpiooutdir); + //gpiosetdir(&gpio4,gpiooutdir); +} + +void bsp_uart_init() +{ + if(__opnfiles__[1]==NULL) + { + //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + uart_t uart = uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,9600,PC6,PC7,-1,-1); + uartmkstreamdev(uart,fd1); + __opnfiles__[1] = fd1; //stdo + __opnfiles__[0] = fd1; //stdi + } + else + { + uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,9600,PC6,PC7,-1,-1); + } +} + + +/* +D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 +D5 PE8 D6 PE9 D7 PE10 D8 PE11 D9 PE12 +D10 PE13 D11 PE14 D12 PE15 D13 PD8 D14 PD9 +D15 PD10 +A0 PF0 = RS FSMC_NE3 PG10 CS FSMC_NWE PD5 W/S +FSMC_NOE PD4 RD +*/ +/*-- GPIOs Configuration -----------------------------------------------------*/ +/* + +-------------------+--------------------+------------------+------------------+ + + SRAM pins assignment + + +-------------------+--------------------+------------------+------------------+ + | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 | + | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 | + | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 | + | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 | + | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 | + | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 | + | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 | + | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+ + | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 | + | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 | + | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+ + | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 | + | | PE15 <-> FSMC_D12 | + +-------------------+--------------------+ +*/ +int bsp_FSMC_init() +{ +#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) +#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) + + gpio_t gpio1 = gpioopen(LCD_RESET); + gpiosetspeed(&gpio1,gpiohighspeed); + gpiosetdir(&gpio1,gpiooutdir); + gpioclr(LCD_RESET); + gpio1 = gpioopen(LCD_CS); + gpiosetspeed(&gpio1,gpiohighspeed); + gpiosetdir(&gpio1,gpiooutdir); + gpioset(LCD_CS); + gpio_t LCD_DBxList[]={ + PD0 ,PD1 ,PD4 ,PD5 ,PD8 ,PD9 ,PD10,PD14,PD15, + PE3 ,PE7 ,PE8 ,PE9 ,PE10,PE11,PE12,PE13,PE14, + PE15 }; + + for(int i=0;i<19;i++) + { + gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); + LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; + gpiosetconfig(&LCD_DBx); + GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); + } + + FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; + FSMC_NORSRAMTimingInitTypeDef p; + + /* Enable FSMC clock */ + RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); + + /*-- FSMC Configuration ------------------------------------------------------*/ + /*----------------------- SRAM Bank 3 ----------------------------------------*/ + /* FSMC_Bank1_NORSRAM3 configuration */ + p.FSMC_AddressSetupTime = 1; + p.FSMC_AddressHoldTime = 0; + p.FSMC_DataSetupTime = getCpuFreq()/14545450 ;// 11; + p.FSMC_BusTurnAroundDuration = 0; + p.FSMC_CLKDivision = 0; + p.FSMC_DataLatency = 0; + p.FSMC_AccessMode = FSMC_AccessMode_A; + /* Color LCD configuration ------------------------------------ + LCD configured as follow: + - Data/Address MUX = Disable + - Memory Type = SRAM + - Data Width = 16bit + - Write Operation = Enable + - Extended Mode = Enable + - Asynchronous Wait = Disable */ + + FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3; + FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; + FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; + FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; + FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; + FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; + FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; + FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; + FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; + FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; + + FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); + + /* Enable FSMC NOR/SRAM Bank1 */ + FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE); + gpioset(LCD_RESET); + gpioclr(LCD_CS); + lcd0.init(&lcd0); + return 1; +} + +void bsp_spi_init() +{ + +} + + +void bsp_iic_init() +{ + +} + +void bsp_SD_init() +{ + +} + + +void vs10XXclearXCS(){} +void vs10XXsetXCS(){} +int vs10XXDREQ() +{ + return 1; +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return 0; +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) +{ + gpioclr(LCD_CS); + *lcd0_CMD=(uint16_t)reg; + *lcd0_DATA=(uint16_t)data; + gpioset(LCD_CS); +} + +uint32_t bsp_lcd0_read_reg(uint32_t reg) +{ + gpioclr(LCD_CS); + *lcd0_CMD=(uint16_t)reg; + uint32_t data=(uint16_t)*lcd0_DATA; + gpioset(LCD_CS); + return data; +} + +void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) +{ + gpioclr(LCD_CS); + *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; + uint16_t* castedBuff=(uint16_t*)buffer; + for(int i=0;i<(int)count;i++) + { + *lcd0_DATA=castedBuff[i]; + } + gpioset(LCD_CS); +} + +void bsp_lcd0_readGRAM(void* buffer,uint32_t count) +{ + gpioclr(LCD_CS); + *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; + uint16_t* castedBuff=(uint16_t*)buffer; + castedBuff[0]=*lcd0_DATA; + for(int i=0;i<(int)count;i++) + { + castedBuff[i]=*lcd0_DATA; + } + gpioset(LCD_CS); +} + + diff --git a/bsp/src/stm32f4/STM32F4Discovery-EXT/bsp.h b/bsp/src/stm32f4/STM32F4Discovery-EXT/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery-EXT/bsp.h @@ -0,0 +1,108 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +#include +#include +#include +/* +#ifndef PD12 + #define PD12 +#endif +#ifndef PD13 + #define PD13 +#endif +*/ +#define __MAX_OPENED_FILES__ 32 +#define __FS_ROOT_SIZE__ 32 + +#define LED1 PD12 +#define LED2 PD13 +#define LCD_RESET PD3 +#define LCD_CS PD7 +#define LCD_BACKL PD13 + +#define GREENLEDON (GPIOD->BSRRL = 1<<12) +#define ORANGELEDON (GPIOD->BSRRL = 1<<13) +#define REDLEDON (GPIOD->BSRRL = 1<<14) +#define BLUELEDON (GPIOD->BSRRL = 1<<15) + +#define GREENLEDOFF (GPIOD->BSRRH = 1<<12) +#define ORANGELEDOFF (GPIOD->BSRRH = 1<<13) +#define REDLEDOFF (GPIOD->BSRRH = 1<<14) +#define BLUELEDOFF (GPIOD->BSRRH = 1<<15) + +extern float VREF0; + +extern uint32_t OSC0; +extern uint32_t currentCpuFreq; + + + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); +extern int bsp_FSMC_init(); + +/* VS1053 */ +extern void clearXCS(); +extern void setXCS(); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); +uint32_t bsp_lcd0_read_reg(uint32_t reg); +void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); +void bsp_lcd0_readGRAM(void *buffer, uint32_t count); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/STM32F4Discovery-EXT/bsp.pri b/bsp/src/stm32f4/STM32F4Discovery-EXT/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery-EXT/bsp.pri @@ -0,0 +1,3 @@ +CPU=stm32f4xxxG +DEFINES+=BSP=\\\"STM32F4Discovery-EXT\\\" +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/STM32F4Discovery-ILI9328-8bits.pro b/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/STM32F4Discovery-ILI9328-8bits.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/STM32F4Discovery-ILI9328-8bits.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp gui + +BSP=STM32F4Discovery-ILI9328-8bits + +UCMODEL=stm32f4 + +SOURCES += bsp.c + +HEADERS += bsp.h + +LIBS+= -lgpio -luart -li2c -lspi + +BSPFILE = bsp.pri + + + diff --git a/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/bsp.c b/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/bsp.c @@ -0,0 +1,378 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + +volatile uint8_t* lcd0_CMD=(volatile uint8_t*)0x60000000; +volatile uint8_t* lcd0_DATA=(volatile uint8_t*)0x61FFFFF0; +terminal_t terminal0; +volatile vs10XXDev audioCodec0; +sdcardDev sdcard2; +blkdevice sdcard2blkdev; +dikpartition sdcard2Part1; +FAT32fs sdcard2FAT32part1; +dikpartition sdcard2Part2; +FAT32fs sdcard2FAT32part2; +dikpartition sdcard2Part3; +FAT32fs sdcard2FAT32part3; +dikpartition sdcard2Part4; +FAT32fs sdcard2FAT32part4; + +LCD_IF_t lcdIF0={ + .init = &bsp_FSMC_init, + .writereg = &bsp_lcd0_write_reg, + .readreg = &bsp_lcd0_read_reg, + .writeGRAM = &bsp_lcd0_writeGRAM, + .readGRAM = &bsp_lcd0_readGRAM +}; + +LCD_t lcd0={ + .interface = &lcdIF0, + .init = &ili9328init, + .paint = &ili9328paint, + .paintText = &ili9328paintText, + .paintFilRect = &ili9328paintFilRect, + .refreshenable = &ili9328refreshenable, + .width= 240, + .height = 320 +}; + + +float VREF0 =(float)3.3; + +int bsp_init() +{ + int i=0; + for(i=0;i<32;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + bsp_FSMC_init(); + bsp_GTerm_init(); + printf("\r================================================================\n\r"); + printf("================================================================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf("================================================================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 + gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); + gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); + gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); + gpiosetspeed(&gpio1,gpiohighspeed); + gpiosetspeed(&gpio2,gpiohighspeed); + gpiosetspeed(&gpio3,gpiohighspeed); + gpiosetspeed(&gpio4,gpiohighspeed); + gpiosetdir(&gpio1,gpiooutdir); + gpiosetdir(&gpio3,gpiooutdir); + gpiosetdir(&gpio2,gpiooutdir); + gpiosetdir(&gpio4,gpiooutdir); +} + +void bsp_uart_init() +{ +// if(__opnfiles__[1]==NULL) +// { +// //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); +// streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); +// uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1); +// uartmkstreamdev(uart,fd1); +// __opnfiles__[1] = fd1; //stdo +// __opnfiles__[0] = fd1; //stdi +// } +// else +// { +// uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); +// } +} + +void bsp_spi_init() +{ + +} + + +int bsp_FSMC_init() +{ +#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) +#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) + + gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10\ + ,PD4,PD5,PD7,PE4}; + for(int i=0;i<12;i++) + { + gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); + LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; + gpiosetconfig(&LCD_DBx); + GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); + } + + FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; + FSMC_NORSRAMTimingInitTypeDef p,readtim; + + /* Enable FSMC clock */ + RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); + + /*-- FSMC Configuration ------------------------------------------------------*/ + /*----------------------- SRAM Bank 3 ----------------------------------------*/ + /* FSMC_Bank1_NORSRAM4 configuration */ + p.FSMC_AddressSetupTime = 3; + p.FSMC_AddressHoldTime = 3; + //ili9328 -> data setup time > 10ns + p.FSMC_DataSetupTime = 1; + if(getCpuFreq()>100*1000*1000) + p.FSMC_DataSetupTime = 2;// 11; + p.FSMC_BusTurnAroundDuration = 0; + p.FSMC_CLKDivision = 0; + p.FSMC_DataLatency = 0; + //ili9328 -> data hold time > 15ns + if(getCpuFreq()>66*1000*1000) + p.FSMC_DataLatency = 1; + p.FSMC_AccessMode = FSMC_AccessMode_A; + + readtim.FSMC_AddressSetupTime = 0xF; + readtim.FSMC_AddressHoldTime = 0xF; + //p.FSMC_DataSetupTime = 9; + readtim.FSMC_DataSetupTime = 0xF ;// 11; + if(getCpuFreq()>100*1000*1000) + readtim.FSMC_DataSetupTime = 0xF;// 11; + readtim.FSMC_BusTurnAroundDuration = 0xf; + readtim.FSMC_CLKDivision = 0; + readtim.FSMC_DataLatency = 0xF; + if(getCpuFreq()>66*1000*1000) + readtim.FSMC_DataLatency = 0xF; + readtim.FSMC_AccessMode = FSMC_AccessMode_A; + + + FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; + FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; + FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; + FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; + FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; + FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; + FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; + FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; + FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readtim; + FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; + + FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); + + FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); + gpioset(LCD_RESET); + gpioclr(LCD_RESET); + delay_100us(500); + gpioset(LCD_RESET); + delay_100us(500); + lcd0.init(&lcd0); + gpioset(LCD_BACKL); + return 1; +} + + +void bsp_iic_init() +{ + +} + +void bsp_SD_init() +{ + +} + + +void vs10XXclearXCS(){} +void vs10XXsetXCS(){} +int vs10XXDREQ() +{ + return 1; +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return 0; +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) +{ + uint8_t* pt8 = (uint8_t*)(void*)® +#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + *lcd0_CMD=pt8[3]; + *lcd0_CMD=pt8[2]; + pt8 = (uint8_t*)(void*)&data; + *lcd0_DATA=pt8[3]; + *lcd0_DATA=pt8[2]; +#else + *lcd0_CMD=pt8[1]; + *lcd0_CMD=pt8[0]; + pt8 = (uint8_t*)(void*)&data; + *lcd0_DATA=pt8[1]; + *lcd0_DATA=pt8[0]; +#endif + +} + +uint32_t bsp_lcd0_read_reg(uint32_t reg) +{ + uint8_t* pt8 = (uint8_t*)(void*)® + uint32_t DATA=0; +#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + *lcd0_CMD=pt8[3]; + *lcd0_CMD=pt8[2]; + pt8 = (uint8_t*)(void*)&DATA; + pt8[3]=*lcd0_DATA; + pt8[2]=*lcd0_DATA; +#else + + *lcd0_CMD=pt8[1]; + *lcd0_CMD=pt8[0]; + pt8 = (uint8_t*)(void*)&DATA; + pt8[1]=*lcd0_DATA; + pt8[0]=*lcd0_DATA; +#endif + + return DATA; +} + +void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) +{ + uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; + uint8_t* pt8 = (uint8_t*)(void*)(®); +#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + *lcd0_CMD=pt8[3]; + *lcd0_CMD=pt8[2]; + pt8 = (uint8_t*)(void*)buffer; + for(int i=0;i<(int)count;i++) + { + *lcd0_DATA=pt8[(2*i) +1]; + *lcd0_DATA=pt8[2*i]; + } +#else + + *lcd0_CMD=pt8[1]; + *lcd0_CMD=pt8[0]; + pt8 = (uint8_t*)(void*)buffer; + for(int i=0;i<(int)count;i++) + { + + *lcd0_DATA=pt8[(2*i) +1]; + *lcd0_DATA=pt8[2*i]; + } +#endif +} + +void bsp_lcd0_readGRAM(void* buffer,uint32_t count) +{ + uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; + uint8_t* pt8 = (uint8_t*)(void*)® +#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + *lcd0_CMD=pt8[3]; + *lcd0_CMD=pt8[2]; + pt8 = (uint8_t*)(void*)buffer; + for(int i=0;i<(int)count;i++) + { + pt8[(2*i) +1]=*lcd0_DATA; + pt8[2*i]=*lcd0_DATA; + } +#else + *lcd0_CMD=pt8[1]; + *lcd0_CMD=pt8[0]; + pt8 = (uint8_t*)(void*)buffer; + /* + * x dummy reads Cf ili9328 datasheet p79! + */ + pt8[0]=*lcd0_DATA; + pt8[0]=*lcd0_DATA; + + for(int i=0;i<(int)count;i++) + { + pt8[(2*i) +1]=*lcd0_DATA; + pt8[2*i]=*lcd0_DATA; + // pt8[(2*i) +1]=(uint8_t)0; + // pt8[(2*i)]=(uint8_t)0; + } +#endif +} + +void bsp_GTerm_init() +{ + if(__opnfiles__[1]==NULL) + { + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); + __opnfiles__[1] = fd1; + } + else + { + + } +} + + + + + diff --git a/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/bsp.h b/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/bsp.h @@ -0,0 +1,127 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* +#ifndef PD12 + #define PD12 +#endif +#ifndef PD13 + #define PD13 +#endif +*/ +#define __MAX_OPENED_FILES__ 32 +#define __FS_ROOT_SIZE__ 32 + +#define LED1 PD12 +#define LED2 PD13 +#define BP3 PA0 + +#define LCD_RESET PD10 +#define LCD_BACKL PE11 + +#define GREENLEDON (GPIOD->BSRRL = 1<<12) +#define ORANGELEDON (GPIOD->BSRRL = 1<<13) +#define REDLEDON (GPIOD->BSRRL = 1<<14) +#define BLUELEDON (GPIOD->BSRRL = 1<<15) + +#define GREENLEDOFF (GPIOD->BSRRH = 1<<12) +#define ORANGELEDOFF (GPIOD->BSRRH = 1<<13) +#define REDLEDOFF (GPIOD->BSRRH = 1<<14) +#define BLUELEDOFF (GPIOD->BSRRH = 1<<15) + +extern float VREF0; +extern LCD_t lcd0; +extern uint32_t OSC0; +extern uint32_t currentCpuFreq; +extern volatile vs10XXDev audioCodec0; +extern sdcardDev sdcard2; +extern blkdevice sdcard2blkdev; +extern dikpartition sdcard2Part1; +extern FAT32fs sdcard2FAT32part1; +extern dikpartition sdcard2Part2; +extern FAT32fs sdcard2FAT32part2; +extern dikpartition sdcard2Part3; +extern FAT32fs sdcard2FAT32part3; +extern dikpartition sdcard2Part4; +extern FAT32fs sdcard2FAT32part4; + + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); +extern void bsp_GTerm_init(); +extern int bsp_FSMC_init(); + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); +uint32_t bsp_lcd0_read_reg(uint32_t reg); +void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); +void bsp_lcd0_readGRAM(void *buffer, uint32_t count); + +/* VS1053 */ +extern void clearXCS(); +extern void setXCS(); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/bsp.pri b/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery-ILI9328-8bits/bsp.pri @@ -0,0 +1,3 @@ +CPU=stm32f4xxxG +DEFINES+=BSP=\\\"STM32F4Discovery-ILI9328-8bits\\\" +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/STM32F4Discovery/STM32F4Discovery.pro b/bsp/src/stm32f4/STM32F4Discovery/STM32F4Discovery.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery/STM32F4Discovery.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp + +BSP=STM32F4Discovery + +UCMODEL=stm32f4 + +SOURCES += bsp.c + +HEADERS += bsp.h + +LIBS+= -lgpio -luart -li2c -lspi + +BSPFILE = bsp.pri + + + diff --git a/bsp/src/stm32f4/STM32F4Discovery/bsp.c b/bsp/src/stm32f4/STM32F4Discovery/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery/bsp.c @@ -0,0 +1,134 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + +float VREF0 =(float)3.3; + +int bsp_init() +{ + int i=0; + for(i=0;i<32;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + printf("\r================================================================\n\r"); + printf("================================================================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf("================================================================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 + gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); + gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); + gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); + gpiosetspeed(&gpio1,gpiohighspeed); + gpiosetspeed(&gpio2,gpiohighspeed); + gpiosetspeed(&gpio3,gpiohighspeed); + gpiosetspeed(&gpio4,gpiohighspeed); + gpiosetdir(&gpio1,gpiooutdir); + gpiosetdir(&gpio3,gpiooutdir); + gpiosetdir(&gpio2,gpiooutdir); + gpiosetdir(&gpio4,gpiooutdir); +} + +void bsp_uart_init() +{ + if(__opnfiles__[1]==NULL) + { + //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1); + uartmkstreamdev(uart,fd1); + __opnfiles__[1] = fd1; //stdo + __opnfiles__[0] = fd1; //stdi + } + else + { + uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); + } +} + +void bsp_spi_init() +{ + +} + + +void bsp_iic_init() +{ + +} + +void bsp_SD_init() +{ + +} + + +void vs10XXclearXCS(){} +void vs10XXsetXCS(){} +int vs10XXDREQ() +{ + return 1; +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return 0; +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + + + + + diff --git a/bsp/src/stm32f4/STM32F4Discovery/bsp.h b/bsp/src/stm32f4/STM32F4Discovery/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery/bsp.h @@ -0,0 +1,95 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +/* +#ifndef PD12 + #define PD12 +#endif +#ifndef PD13 + #define PD13 +#endif +*/ +#define __MAX_OPENED_FILES__ 32 +#define __FS_ROOT_SIZE__ 32 + +#define LED1 PD12 +#define LED2 PD13 + +#define GREENLEDON (GPIOD->BSRRL = 1<<12) +#define ORANGELEDON (GPIOD->BSRRL = 1<<13) +#define REDLEDON (GPIOD->BSRRL = 1<<14) +#define BLUELEDON (GPIOD->BSRRL = 1<<15) + +#define GREENLEDOFF (GPIOD->BSRRH = 1<<12) +#define ORANGELEDOFF (GPIOD->BSRRH = 1<<13) +#define REDLEDOFF (GPIOD->BSRRH = 1<<14) +#define BLUELEDOFF (GPIOD->BSRRH = 1<<15) + +extern float VREF0; + +extern uint32_t OSC0; +extern uint32_t currentCpuFreq; + + + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); + +/* VS1053 */ +extern void clearXCS(); +extern void setXCS(); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/STM32F4Discovery/bsp.pri b/bsp/src/stm32f4/STM32F4Discovery/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Discovery/bsp.pri @@ -0,0 +1,3 @@ +CPU=stm32f4xxxG +DEFINES+=BSP=\\\"STM32F4Discovery\\\" +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/STM32F4Eval/STM32F4Eval.pro b/bsp/src/stm32f4/STM32F4Eval/STM32F4Eval.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Eval/STM32F4Eval.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp gui + +BSP=STM32F4Eval + +UCMODEL=stm32f4 + +SOURCES += bsp.c + +HEADERS += bsp.h +LIBS+= -lgpio -luart -li2c -lspi + +BSPFILE = bsp.pri + + + diff --git a/bsp/src/stm32f4/STM32F4Eval/bsp.c b/bsp/src/stm32f4/STM32F4Eval/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Eval/bsp.c @@ -0,0 +1,363 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +uint32_t OSC0 =8000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + +LCD_IF_t lcdIF0={ + .init = &bsp_FSMC_init, + .writereg = &bsp_lcd0_write_reg, + .readreg = &bsp_lcd0_read_reg, + .writeGRAM = &bsp_lcd0_writeGRAM, + .readGRAM = &bsp_lcd0_readGRAM +}; + +LCD_t lcd0={ + .interface = &lcdIF0, + .init = &ili9328init, + .paint = &ili9328paint, + .paintText = &ili9328paintText, + .paintFilRect = &ili9328paintFilRect, + .getPix = &ili9328getPix, + .refreshenable = &ili9328refreshenable, + .width= 240, + .height = 320 +}; + +terminal_t terminal0; + + +volatile int16_t* lcd0_CMD=(volatile int16_t*) (0x60000000 | 0x08000000); +volatile int16_t* lcd0_DATA=((volatile int16_t*)(0x60000000 | 0x08000002)); + +float VREF0 =(float)3.3; + +int bsp_init() +{ + int i=0; + for(i=0;i<32;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + bsp_iic_init(); + bsp_FSMC_init(); + bsp_GTerm_init(); + printf("\r=====================\n\r"); + printf( "=====================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf( "=====================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + gpio_t gpio1 = gpioopen(LED1); + gpio_t gpio2 = gpioopen(LED2); + gpio_t gpio3 = gpioopen(LED3); + gpiosetspeed(&gpio1,gpiohighspeed); + gpiosetspeed(&gpio2,gpiohighspeed); + gpiosetspeed(&gpio3,gpiohighspeed); + gpiosetdir(&gpio1,gpiooutdir); + gpiosetdir(&gpio2,gpiooutdir); + gpiosetdir(&gpio3,gpiooutdir); +} + +void bsp_uart_init() +{ + //if(__opnfiles__[1]==NULL) + //{ + //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); + // 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; + //} + //else + //{ + uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); + //} +} + +/* +D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 +D5 PE8 D6 PE9 D7 PE10 D8 PE11 D9 PE12 +D10 PE13 D11 PE14 D12 PE15 D13 PD8 D14 PD9 +D15 PD10 +A0 PF0 = RS FSMC_NE3 PG10 CS FSMC_NWE PD5 W/S +FSMC_NOE PD4 RD +*/ +/*-- GPIOs Configuration -----------------------------------------------------*/ +/* + +-------------------+--------------------+------------------+------------------+ + + SRAM pins assignment + + +-------------------+--------------------+------------------+------------------+ + | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 | + | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 | + | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 | + | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 | + | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 | + | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 | + | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 | + | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+ + | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 | + | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 | + | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+ + | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 | + | | PE15 <-> FSMC_D12 | + +-------------------+--------------------+ +*/ +int bsp_FSMC_init() +{ +#define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) +#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) + + gpio_t LCD_DBxList[]={ + PD0 ,PD1 ,PD4 ,PD5 ,PD8 ,PD9 ,PD10,PD11,PD12,PD13,PD14,PD15, + PE0 ,PE1 ,PE3 ,PE4 ,PE7 ,PE8 ,PE9 ,PE10,PE11,PE12,PE13,PE14, + PE15,PF0 ,PF1 ,PF2 ,PF3 ,PF4 ,PF5 ,PF12,PF13,PF14,PF15,PG0 , + PG1 ,PG2 ,PG3 ,PG4 ,PG5 ,PG9 ,PG10 + }; + + for(int i=0;i<43;i++) + { + gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); + LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; + gpiosetconfig(&LCD_DBx); + GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); + } + + FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; + FSMC_NORSRAMTimingInitTypeDef p,readtim; + + /* Enable FSMC clock */ + RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); + + /*-- FSMC Configuration ------------------------------------------------------*/ + /*----------------------- SRAM Bank 3 ----------------------------------------*/ + /* FSMC_Bank1_NORSRAM3 configuration */ + p.FSMC_AddressSetupTime = 0xf; + p.FSMC_AddressHoldTime = 0xf; + //ili9328 -> data setup time > 10ns + p.FSMC_DataSetupTime = 0xf; + if(getCpuFreq()>100*1000*1000) + p.FSMC_DataSetupTime = 0xf;// 11; + p.FSMC_BusTurnAroundDuration = 0xf; + p.FSMC_CLKDivision = 0; + p.FSMC_DataLatency = 0xf; + //ili9328 -> data hold time > 15ns + if(getCpuFreq()>66*1000*1000) + p.FSMC_DataLatency = 0xf; + p.FSMC_AccessMode = FSMC_AccessMode_A; + + readtim.FSMC_AddressSetupTime = 0xf; + readtim.FSMC_AddressHoldTime = 0xf; + //p.FSMC_DataSetupTime = 9; + readtim.FSMC_DataSetupTime = 0xf ;// 11; + if(getCpuFreq()>100*1000*1000) + readtim.FSMC_DataSetupTime = 0xf;// 11; + readtim.FSMC_BusTurnAroundDuration = 0xf; + readtim.FSMC_CLKDivision = 0; + readtim.FSMC_DataLatency = 0xf; + if(getCpuFreq()>66*1000*1000) + readtim.FSMC_DataLatency = 0xf; + readtim.FSMC_AccessMode = FSMC_AccessMode_A; + /* Color LCD configuration ------------------------------------ + LCD configured as follow: + - Data/Address MUX = Disable + - Memory Type = SRAM + - Data Width = 16bit + - Write Operation = Enable + - Extended Mode = Enable + - Asynchronous Wait = Disable */ + + FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3; + FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; + FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; + FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; + FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; + FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; + FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; + FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; + FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readtim; + FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; + + FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); + + /* Enable FSMC NOR/SRAM Bank1 */ + FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE); + + + p.FSMC_AddressSetupTime = getCpuFreq()/50000000; + p.FSMC_AddressHoldTime = 0; + p.FSMC_DataSetupTime = getCpuFreq()/25000000; + p.FSMC_BusTurnAroundDuration = 1; + p.FSMC_CLKDivision = 0; + p.FSMC_DataLatency = 0; + p.FSMC_AccessMode = FSMC_AccessMode_A; + + FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2; + FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; + FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM; + FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; + FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; + FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; + FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; + FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; + FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; + FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; + + FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); + + /*!< Enable FSMC Bank1_SRAM2 Bank */ + FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM2, ENABLE); + lcd0.init(&lcd0); + return 1; +} + +void bsp_spi_init() +{ + +} + + +void bsp_iic_init() +{ + i2copenandconfig(i2c1,0,10000,PB9,PB6); +} + +void bsp_SD_init() +{ + gpio_t SDIO_DBxList[]={PC8 ,PC9 ,PC10 ,PC11 ,PC12,PD2}; + for(int i=0;i<6;i++) + { + gpio_t SDIO_DBx = gpioopen(SDIO_DBxList[i]); + SDIO_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; + gpiosetconfig(&SDIO_DBx); + GPIO_PinAFConfig(GPIOGETPORT(SDIO_DBx), (uint8_t)(SDIO_DBx & 0xF), GPIO_AF_SDIO); + } +} + +void vs10XXclearXCS(){} +void vs10XXsetXCS(){} +int vs10XXDREQ() +{ + return 1; +} + + +void bsppowersdcard(char onoff) //always ON +{ + +} + +char bspsdcardpresent() +{ + return 0; +} + +char bspsdcardwriteprotected() +{ + return 0; +} + +void bspsdcardselect(char YESNO) +{ + +} + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) +{ + *lcd0_CMD=(uint16_t)reg; + *lcd0_DATA=(uint16_t)data; +} + +uint32_t bsp_lcd0_read_reg(uint32_t reg) +{ + *lcd0_CMD=(uint16_t)reg; + return (uint16_t)*lcd0_DATA; +} + +void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) +{ + *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; + uint16_t* castedBuff=(uint16_t*)buffer; + for(int i=0;i<(int)count;i++) + { + *lcd0_DATA=castedBuff[i]; + } +} + +void bsp_lcd0_readGRAM(void* buffer,uint32_t count) +{ + *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; + uint16_t* castedBuff=(uint16_t*)buffer; + castedBuff[0]=*lcd0_DATA; + for(int i=0;i<(int)count;i++) + { + castedBuff[i]=*lcd0_DATA; + } +} + +void bsp_GTerm_init() +{ + if(__opnfiles__[1]==NULL) + { + streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); + ili9328paintFilRect(&lcd0,0,0,240,320,0x7FFF,5,0); + terminal_init(&terminal0,&lcd0,&ComicSansMS_8,fd1); + __opnfiles__[1] = fd1; + } + else + { + + } +} + + + diff --git a/bsp/src/stm32f4/STM32F4Eval/bsp.h b/bsp/src/stm32f4/STM32F4Eval/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Eval/bsp.h @@ -0,0 +1,94 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2011, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include +#include +#include +#include +#include + +#define __MAX_OPENED_FILES__ 4 +#define __FS_ROOT_SIZE__ 4 + + + +#define LED1 PG6 +#define LED2 PG8 +#define LED3 PI9 +#define LED4 PC7 + + +extern float VREF0; + +extern uint32_t currentCpuFreq; +extern LCD_t lcd0; + + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); +extern void bsp_SD_init(); +extern void bsp_GTerm_init(); +extern int bsp_FSMC_init(); + +/* VS1053 */ +extern void clearXCS(); +extern void setXCS(); +extern int vs10XXDREQ(); + +/* SD CARD */ +void bsppowersdcard(char onoff); +char bspsdcardpresent(); +void bspsdcardselect(char YESNO); +char bspsdcardwriteprotected(); + + +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); +uint32_t bsp_lcd0_read_reg(uint32_t reg); +void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); +void bsp_lcd0_readGRAM(void *buffer, uint32_t count); + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/STM32F4Eval/bsp.pri b/bsp/src/stm32f4/STM32F4Eval/bsp.pri new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/STM32F4Eval/bsp.pri @@ -0,0 +1,3 @@ +CPU=stm32f4xxxG +DEFINES+=BSP=\\\"STM32F4Eval\\\" +UCMODEL=stm32f4 diff --git a/bsp/src/stm32f4/stm32f4.pro b/bsp/src/stm32f4/stm32f4.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/stm32f4.pro @@ -0,0 +1,20 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS += STM32F4Discovery \ + M4Stick \ + M4StickV2 \ + SOLAR_LFR_PSU \ + BEAGLESYNTH \ + STM32F4Eval \ + STM32F4Discovery-EXT \ + STM32F4Discovery-ILI9328-8bits \ + OPLAYER \ + STM32-E407 \ + STM32F429Discovery + + + + + + + diff --git a/examples/BeagleSynthHello/BeagleSynthHello.pro b/examples/BeagleSynthHello/BeagleSynthHello.pro --- a/examples/BeagleSynthHello/BeagleSynthHello.pro +++ b/examples/BeagleSynthHello/BeagleSynthHello.pro @@ -1,12 +1,15 @@ -TEMPLATE = app +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app + BSP = BEAGLESYNTH + #BSP = SOLAR_LFR_PSU + + SOURCES += \ + main.c + } +} -UCMODEL=stm32f4 -BSP = BEAGLESYNTH -#BSP = SOLAR_LFR_PSU -SOURCES += \ - main.c - diff --git a/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro b/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro --- a/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro +++ b/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro @@ -1,22 +1,18 @@ -TEMPLATE = app - +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app -UCMODEL=stm32f4 -DEFINES += CPUFREQ=80000000 + DEFINES += CPUFREQ=80000000 -BSP = BEAGLESYNTH -#BSP = SOLAR_LFR_PSU -#BSP = STM32F4Eval + BSP = BEAGLESYNTH + #BSP = SOLAR_LFR_PSU + #BSP = STM32F4Eval -SOURCES += \ - main.c + 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/M4StickV2/M4StickV2.pro b/examples/M4StickV2/M4StickV2.pro --- a/examples/M4StickV2/M4StickV2.pro +++ b/examples/M4StickV2/M4StickV2.pro @@ -1,12 +1,15 @@ -TEMPLATE = app +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app + + BSP=M4StickV2 -UCMODEL=stm32f4 + DEFINES += CPUFREQ=80000000 -BSP=M4StickV2 + SOURCES += \ + main.c + + } +} -DEFINES += CPUFREQ=80000000 - -SOURCES += \ - main.c - diff --git a/examples/N25Q128_test/N25Q128_test.pro b/examples/N25Q128_test/N25Q128_test.pro --- a/examples/N25Q128_test/N25Q128_test.pro +++ b/examples/N25Q128_test/N25Q128_test.pro @@ -1,11 +1,16 @@ -TEMPLATE = app +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app + + BSP = SOLAR_LFR_PSU + + LIBS += -lN25Q128 + + SOURCES += \ + main.c + + } +} -UCMODEL=stm32f4 -BSP = SOLAR_LFR_PSU -LIBS += -lN25Q128 - -SOURCES += \ - main.c - diff --git a/examples/QtTest/test.pro b/examples/QtTest/test.pro --- a/examples/QtTest/test.pro +++ b/examples/QtTest/test.pro @@ -1,9 +1,13 @@ -TEMPLATE = app +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app -UCMODEL=stm32f4 + BSP = SOLAR_LFR_PSU -BSP = SOLAR_LFR_PSU + SOURCES += \ + main.c + } +} -SOURCES += \ - main.c + diff --git a/examples/SDCARD/SDCARD.pro b/examples/SDCARD/SDCARD.pro --- a/examples/SDCARD/SDCARD.pro +++ b/examples/SDCARD/SDCARD.pro @@ -1,9 +1,15 @@ -TEMPLATE = app +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app -UCMODEL=stm32f4 -BSP = STM32F4Discovery + BSP = STM32F4Discovery -SOURCES += \ - main.c + SOURCES += \ + main.c + } +} + + + diff --git a/examples/SOLAR_PSU_HELLO/hello.pro b/examples/SOLAR_PSU_HELLO/hello.pro --- a/examples/SOLAR_PSU_HELLO/hello.pro +++ b/examples/SOLAR_PSU_HELLO/hello.pro @@ -1,15 +1,19 @@ -TEMPLATE = app -CONFIG += cpu +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app + CONFIG += cpu + + BSP = OPLAYER + #BSP = STM32F4Discovery-ILI9328-8bits + + DEFINES += CPUFREQ=40000000 -UCMODEL=stm32f4 -BSP = OPLAYER -#BSP = STM32F4Discovery-ILI9328-8bits + SOURCES += \ + main.c \ + test_lcd.c -DEFINES += CPUFREQ=40000000 + } +} -SOURCES += \ - main.c \ - test_lcd.c - diff --git a/examples/STM32F4IT/STM32F4IT.pro b/examples/STM32F4IT/STM32F4IT.pro --- a/examples/STM32F4IT/STM32F4IT.pro +++ b/examples/STM32F4IT/STM32F4IT.pro @@ -1,10 +1,13 @@ -TEMPLATE = app - -UCMODEL=stm32f4 +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app -BSP = STM32F4Discovery + BSP = STM32F4Discovery -SOURCES += \ - main.c + SOURCES += \ + main.c + } +} + diff --git a/examples/TEST_CMSIS_FFT/TEST_CMSIS_FFT.pro b/examples/TEST_CMSIS_FFT/TEST_CMSIS_FFT.pro --- a/examples/TEST_CMSIS_FFT/TEST_CMSIS_FFT.pro +++ b/examples/TEST_CMSIS_FFT/TEST_CMSIS_FFT.pro @@ -1,13 +1,21 @@ -TEMPLATE = app +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app -UCMODEL=stm32f4 -DEFINES += CPUFREQ=160000000 + DEFINES += CPUFREQ=160000000 + + #BSP = BEAGLESYNTH + #BSP = SOLAR_LFR_PSU + + BSP = STM32F4Eval -#BSP = BEAGLESYNTH -#BSP = SOLAR_LFR_PSU + SOURCES += \ + main.c + } +} -BSP = STM32F4Eval + + -SOURCES += \ - main.c + diff --git a/examples/TEST_SIMULATOR/TEST_SIMULATOR.pro b/examples/TEST_SIMULATOR/TEST_SIMULATOR.pro --- a/examples/TEST_SIMULATOR/TEST_SIMULATOR.pro +++ b/examples/TEST_SIMULATOR/TEST_SIMULATOR.pro @@ -1,12 +1,15 @@ -TEMPLATE = app +!isEmpty( UCMODEL ) { + contains( UCMODEL, simulator ){ + TEMPLATE = app + BSP = SIMULATOR -UCMODEL=simulator -BSP = SIMULATOR + DEFINES += CPUFREQ=100000000 -DEFINES += CPUFREQ=100000000 + SOURCES += \ + main.c \ + test_lcd.c \ + test_SDCARD.c + } +} -SOURCES += \ - main.c \ - test_lcd.c \ - test_SDCARD.c diff --git a/examples/examples.pro b/examples/examples.pro --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,22 +1,30 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += QtTest/test.pro \ + + +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + SUBDIRS += \ + QtTest/test.pro \ SOLAR_PSU_HELLO/hello.pro \ SDCARD \ STM32F4IT \ M4StickV2 \ lcdHello \ BeagleSynthHello \ - lcdTerminal \ + lcdTerminal \ BeagleSynthHelloSupMon \ TEST_CMSIS_FFT \ N25Q128_test \ - ssd2119Tests \ + ssd2119Tests + } + contains( UCMODEL, simulator ){ + SUBDIRS += \ TEST_SIMULATOR + } +} - - diff --git a/examples/lcdHello/lcdHello.pro b/examples/lcdHello/lcdHello.pro --- a/examples/lcdHello/lcdHello.pro +++ b/examples/lcdHello/lcdHello.pro @@ -1,11 +1,18 @@ -TEMPLATE = app +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app -UCMODEL=stm32f4 + BSP = STM32F4Eval -BSP = STM32F4Eval + DEFINES += CPUFREQ=160000000 -DEFINES += CPUFREQ=160000000 + SOURCES += \ + main.c -SOURCES += \ - main.c + } +} + + + + diff --git a/examples/lcdTerminal/lcdTerminal.pro b/examples/lcdTerminal/lcdTerminal.pro --- a/examples/lcdTerminal/lcdTerminal.pro +++ b/examples/lcdTerminal/lcdTerminal.pro @@ -1,11 +1,18 @@ -TEMPLATE = app -CONFIG += audio -UCMODEL=stm32f4 +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app + CONFIG += audio -BSP = STM32F4Eval + BSP = STM32F4Eval + + DEFINES += CPUFREQ=168000000 -DEFINES += CPUFREQ=168000000 + SOURCES += \ + main.c -SOURCES += \ - main.c + } +} + + + diff --git a/examples/ssd2119Tests/ssd2119Tests.pro b/examples/ssd2119Tests/ssd2119Tests.pro --- a/examples/ssd2119Tests/ssd2119Tests.pro +++ b/examples/ssd2119Tests/ssd2119Tests.pro @@ -1,10 +1,14 @@ -TEMPLATE = app +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + TEMPLATE = app + + DEFINES += CPUFREQ=120000000 + + BSP = STM32F4Discovery-EXT + + SOURCES += \ + main.c + } +} -UCMODEL=stm32f4 -DEFINES += CPUFREQ=120000000 - -BSP = STM32F4Discovery-EXT - -SOURCES += \ - main.c diff --git a/libuc2.pro b/libuc2.pro --- a/libuc2.pro +++ b/libuc2.pro @@ -1,11 +1,8 @@ TEMPLATE = subdirs CONFIG += ordered + SUBDIRS += src/lib.pro \ bsp\ examples -binfiles.files = bin/dfu.py -binfiles.path = $$[QT_INSTALL_BINS] -INSTALLS+=binfiles - diff --git a/mkspecs/features/libuc2.prf b/mkspecs/features/libuc2.prf --- a/mkspecs/features/libuc2.prf +++ b/mkspecs/features/libuc2.prf @@ -30,15 +30,17 @@ INCLUDEPATH += $$[QT_INSTALL_HEADERS] \ $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/FONTS \ $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/Widgets -# -# Microcontroler switch -# -# +isEmpty( UCMODEL ) { + message("You didn't define any target architecture, default is stm32f4") + message("To define a target architecture set the UCMODEL variable to the desired architecture") + #UCMODEL=stm32f4 +} + contains( TEMPLATE, app ) { !isEmpty( BSP ) { include(./boards/$$BSP/bsp.pri) } - INCLUDEPATH+= $$[QT_INSTALL_PREFIX]/bsp/src/$$BSP + INCLUDEPATH+= $$[QT_INSTALL_PREFIX]/bsp/src/$$UCMODEL/$$BSP CONFIG += link_prl OBJECTS_DIR=obj-$$UCMODEL DESTDIR=bin-$$UCMODEL diff --git a/src/common/AUDIO/CS43L22/CS43L22.pro b/src/common/AUDIO/CS43L22/CS43L22.pro --- a/src/common/AUDIO/CS43L22/CS43L22.pro +++ b/src/common/AUDIO/CS43L22/CS43L22.pro @@ -1,5 +1,5 @@ -TEMPLATE = subdirs -CONFIG += ordered +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = CS43L22 -SUBDIRS += ./CS43L22_STM32F4.pro \ - ./CS43L22_SIMULATOR.pro +SOURCES += CS43L22.c diff --git a/src/common/AUDIO/CS43L22/CS43L22_SIMULATOR.pro b/src/common/AUDIO/CS43L22/CS43L22_SIMULATOR.pro deleted file mode 100644 --- a/src/common/AUDIO/CS43L22/CS43L22_SIMULATOR.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = CS43L22 - -SOURCES += CS43L22.c - - -UCMODEL=simulator - - - diff --git a/src/common/AUDIO/CS43L22/CS43L22_STM32F4.pro b/src/common/AUDIO/CS43L22/CS43L22_STM32F4.pro deleted file mode 100644 --- a/src/common/AUDIO/CS43L22/CS43L22_STM32F4.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = CS43L22 - -SOURCES += CS43L22.c - - -UCMODEL=stm32f4 - - - - diff --git a/src/common/AUDIO/VS10XX/VS10XX.pro b/src/common/AUDIO/VS10XX/VS10XX.pro --- a/src/common/AUDIO/VS10XX/VS10XX.pro +++ b/src/common/AUDIO/VS10XX/VS10XX.pro @@ -1,3 +1,10 @@ -TEMPLATE = subdirs -SUBDIRS += ./VS10XX_STM32F4.pro \ - ./VS10XX_SIMULATOR.pro +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = vs10XX + +SOURCES += VS10XX.c + + +HEADERS += \ + ../../../../include/AUDIO/VS10XX.h + diff --git a/src/common/AUDIO/VS10XX/VS10XX_SIMULATOR.pro b/src/common/AUDIO/VS10XX/VS10XX_SIMULATOR.pro deleted file mode 100644 --- a/src/common/AUDIO/VS10XX/VS10XX_SIMULATOR.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = vs10XX - -SOURCES += VS10XX.c - -UCMODEL=simulator - -HEADERS += \ - ../../../../include/AUDIO/VS10XX.h - - diff --git a/src/common/AUDIO/VS10XX/VS10XX_STM32F4.pro b/src/common/AUDIO/VS10XX/VS10XX_STM32F4.pro deleted file mode 100644 --- a/src/common/AUDIO/VS10XX/VS10XX_STM32F4.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = vs10XX - -SOURCES += VS10XX.c - - -UCMODEL=stm32f4 - -HEADERS += \ - ../../../../include/AUDIO/VS10XX.h - - diff --git a/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.pro b/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.pro --- a/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.pro +++ b/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.pro @@ -1,3 +1,7 @@ -TEMPLATE = subdirs -SUBDIRS += ./24LC0X_STM32F4.pro \ - ./24LC0X_SIMULATOR.pro +TEMPLATE = lib +CONFIG += libuc2lib + +SOURCES += 24LC0X.c +TARGET = 24LC0X + + diff --git a/src/common/EEPROMS/24LCXX/24LC0X/24LC0X_SIMULATOR.pro b/src/common/EEPROMS/24LCXX/24LC0X/24LC0X_SIMULATOR.pro deleted file mode 100644 --- a/src/common/EEPROMS/24LCXX/24LC0X/24LC0X_SIMULATOR.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib - -SOURCES += 24LC0X.c -TARGET = 24LC0X -UCMODEL=simulator - diff --git a/src/common/EEPROMS/24LCXX/24LC0X/24LC0X_STM32F4.pro b/src/common/EEPROMS/24LCXX/24LC0X/24LC0X_STM32F4.pro deleted file mode 100644 --- a/src/common/EEPROMS/24LCXX/24LC0X/24LC0X_STM32F4.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib - -SOURCES += 24LC0X.c -TARGET = 24LC0X - -UCMODEL=stm32f4 - diff --git a/src/common/EEPROMS/N25Q128/N25Q128.pro b/src/common/EEPROMS/N25Q128/N25Q128.pro --- a/src/common/EEPROMS/N25Q128/N25Q128.pro +++ b/src/common/EEPROMS/N25Q128/N25Q128.pro @@ -1,5 +1,8 @@ -TEMPLATE = subdirs +TEMPLATE = lib +CONFIG += libuc2lib + +SOURCES += N25Q128.c +TARGET = N25Q128 -SUBDIRS += ./N25Q128_SIMULATOR.pro \ - ./N25Q128_STM32F4.pro + diff --git a/src/common/EEPROMS/N25Q128/N25Q128_SIMULATOR.pro b/src/common/EEPROMS/N25Q128/N25Q128_SIMULATOR.pro deleted file mode 100644 --- a/src/common/EEPROMS/N25Q128/N25Q128_SIMULATOR.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib - -SOURCES += N25Q128.c -TARGET = N25Q128 - -UCMODEL=simulator - - diff --git a/src/common/EEPROMS/N25Q128/N25Q128_STM32F4.pro b/src/common/EEPROMS/N25Q128/N25Q128_STM32F4.pro deleted file mode 100644 --- a/src/common/EEPROMS/N25Q128/N25Q128_STM32F4.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib - -SOURCES += N25Q128.c -TARGET = N25Q128 -UCMODEL=stm32f4 diff --git a/src/common/FILE_SYSTEM/DIRENT/DIRENT.pro b/src/common/FILE_SYSTEM/DIRENT/DIRENT.pro --- a/src/common/FILE_SYSTEM/DIRENT/DIRENT.pro +++ b/src/common/FILE_SYSTEM/DIRENT/DIRENT.pro @@ -1,6 +1,8 @@ -TEMPLATE = subdirs -CONFIG += ordered +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = ucdirent -SUBDIRS += ./dirent_STM32F4.pro \ - ./dirent_SIMULATOR.pro +SOURCES += \ + ucdirent.c + diff --git a/src/common/FILE_SYSTEM/DIRENT/dirent_SIMULATOR.pro b/src/common/FILE_SYSTEM/DIRENT/dirent_SIMULATOR.pro deleted file mode 100644 --- a/src/common/FILE_SYSTEM/DIRENT/dirent_SIMULATOR.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = ucdirent - -SOURCES += \ - ucdirent.c - - -UCMODEL=simulator - - - diff --git a/src/common/FILE_SYSTEM/DIRENT/dirent_STM32F4.pro b/src/common/FILE_SYSTEM/DIRENT/dirent_STM32F4.pro deleted file mode 100644 --- a/src/common/FILE_SYSTEM/DIRENT/dirent_STM32F4.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = ucdirent - -SOURCES += \ - ucdirent.c - -UCMODEL=stm32f4 diff --git a/src/common/FILE_SYSTEM/FAT32/FAT32.pro b/src/common/FILE_SYSTEM/FAT32/FAT32.pro --- a/src/common/FILE_SYSTEM/FAT32/FAT32.pro +++ b/src/common/FILE_SYSTEM/FAT32/FAT32.pro @@ -1,5 +1,11 @@ -TEMPLATE = subdirs -CONFIG += ordered +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = fat32 -SUBDIRS += ./fat32_STM32F4.pro \ - ./fat32_SIMULATOR.pro +SOURCES += \ + fat32.c + + +HEADERS += \ + ../../../includes/fat32.h + diff --git a/src/common/FILE_SYSTEM/FAT32/fat32_SIMULATOR.pro b/src/common/FILE_SYSTEM/FAT32/fat32_SIMULATOR.pro deleted file mode 100644 --- a/src/common/FILE_SYSTEM/FAT32/fat32_SIMULATOR.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = fat32 - -SOURCES += \ - fat32.c - -UCMODEL=simulator - - -HEADERS += \ - ../../../includes/fat32.h - diff --git a/src/common/FILE_SYSTEM/FAT32/fat32_STM32F4.pro b/src/common/FILE_SYSTEM/FAT32/fat32_STM32F4.pro deleted file mode 100644 --- a/src/common/FILE_SYSTEM/FAT32/fat32_STM32F4.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = fat32 - -SOURCES += \ - fat32.c - - -UCMODEL=stm32f4 - -HEADERS += \ - ../../../includes/fat32.h - diff --git a/src/common/FILE_SYSTEM/FILE_SYSTEM.pro b/src/common/FILE_SYSTEM/FILE_SYSTEM.pro --- a/src/common/FILE_SYSTEM/FILE_SYSTEM.pro +++ b/src/common/FILE_SYSTEM/FILE_SYSTEM.pro @@ -1,7 +1,10 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += SDCARD \ - MBR \ +SUBDIRS += MBR \ DIRENT \ FAT32 + +!contains( UCMODEL , simulator){ + SUBDIRS += SDCARD \ +} diff --git a/src/common/FILE_SYSTEM/MBR/MBR.pro b/src/common/FILE_SYSTEM/MBR/MBR.pro --- a/src/common/FILE_SYSTEM/MBR/MBR.pro +++ b/src/common/FILE_SYSTEM/MBR/MBR.pro @@ -1,5 +1,9 @@ -TEMPLATE = subdirs -CONFIG += ordered +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = mbr -SUBDIRS += ./mbr_STM32F4.pro \ - ./mbr_SIMULATOR.pro +SOURCES += \ + mbr.c + + + diff --git a/src/common/FILE_SYSTEM/MBR/mbr_SIMULATOR.pro b/src/common/FILE_SYSTEM/MBR/mbr_SIMULATOR.pro deleted file mode 100644 --- a/src/common/FILE_SYSTEM/MBR/mbr_SIMULATOR.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = mbr - -SOURCES += \ - mbr.c - -UCMODEL=simulator - - diff --git a/src/common/FILE_SYSTEM/MBR/mbr_STM32F4.pro b/src/common/FILE_SYSTEM/MBR/mbr_STM32F4.pro deleted file mode 100644 --- a/src/common/FILE_SYSTEM/MBR/mbr_STM32F4.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = mbr - -SOURCES += \ - mbr.c - -UCMODEL=stm32f4 - diff --git a/src/common/FILE_SYSTEM/SDCARD/SDCARD.pro b/src/common/FILE_SYSTEM/SDCARD/SDCARD.pro --- a/src/common/FILE_SYSTEM/SDCARD/SDCARD.pro +++ b/src/common/FILE_SYSTEM/SDCARD/SDCARD.pro @@ -1,4 +1,8 @@ -TEMPLATE = subdirs -CONFIG += ordered +!contains( UCMODEL , simulator){ + TEMPLATE = lib + CONFIG += libuc2lib + TARGET = sdcard -SUBDIRS += ./sdcard_STM32F4.pro + SOURCES += \ + sdcard.c +} diff --git a/src/common/FILE_SYSTEM/SDCARD/sdcard_STM32F4.pro b/src/common/FILE_SYSTEM/SDCARD/sdcard_STM32F4.pro deleted file mode 100644 --- a/src/common/FILE_SYSTEM/SDCARD/sdcard_STM32F4.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = sdcard - -SOURCES += \ - sdcard.c - -UCMODEL=stm32f4 - diff --git a/src/common/GRAPHIC/CONTROLERS/ILI9328/ILI9328.pro b/src/common/GRAPHIC/CONTROLERS/ILI9328/ILI9328.pro --- a/src/common/GRAPHIC/CONTROLERS/ILI9328/ILI9328.pro +++ b/src/common/GRAPHIC/CONTROLERS/ILI9328/ILI9328.pro @@ -1,5 +1,9 @@ -TEMPLATE = subdirs -CONFIG += ordered +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = ili9328 -SUBDIRS += ./ili9328_STM32F4.pro \ - ./ili9328_SIMULATOR.pro +SOURCES += \ + ili9328.c + + + diff --git a/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328_SIMULATOR.pro b/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328_SIMULATOR.pro deleted file mode 100644 --- a/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328_SIMULATOR.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = ili9328 - -SOURCES += \ - ili9328.c - - -UCMODEL=simulator - diff --git a/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328_STM32F4.pro b/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328_STM32F4.pro deleted file mode 100644 --- a/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328_STM32F4.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = ili9328 - -SOURCES += \ - ili9328.c - -DEFINES -= __OPTIMIZED_MATH - - -UCMODEL=stm32f4 - diff --git a/src/common/GRAPHIC/CONTROLERS/SSD2119/SSD2119.pro b/src/common/GRAPHIC/CONTROLERS/SSD2119/SSD2119.pro --- a/src/common/GRAPHIC/CONTROLERS/SSD2119/SSD2119.pro +++ b/src/common/GRAPHIC/CONTROLERS/SSD2119/SSD2119.pro @@ -1,5 +1,8 @@ -TEMPLATE = subdirs -CONFIG += ordered +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = ssd2119 -SUBDIRS += ./ssd2119_STM32F4.pro \ - ./ssd2119_SIMULATOR.pro +SOURCES += \ + ssd2119.c + + diff --git a/src/common/GRAPHIC/CONTROLERS/SSD2119/ssd2119_SIMULATOR.pro b/src/common/GRAPHIC/CONTROLERS/SSD2119/ssd2119_SIMULATOR.pro deleted file mode 100644 --- a/src/common/GRAPHIC/CONTROLERS/SSD2119/ssd2119_SIMULATOR.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = ssd2119 - -SOURCES += \ - ssd2119.c - - - -UCMODEL=simulator diff --git a/src/common/GRAPHIC/CONTROLERS/SSD2119/ssd2119_STM32F4.pro b/src/common/GRAPHIC/CONTROLERS/SSD2119/ssd2119_STM32F4.pro deleted file mode 100644 --- a/src/common/GRAPHIC/CONTROLERS/SSD2119/ssd2119_STM32F4.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = ssd2119 - -SOURCES += \ - ssd2119.c - -DEFINES -= __OPTIMIZED_MATH - - -UCMODEL=stm32f4 diff --git a/src/common/GRAPHIC/GUI/FONTS/FONTS.pro b/src/common/GRAPHIC/GUI/FONTS/FONTS.pro --- a/src/common/GRAPHIC/GUI/FONTS/FONTS.pro +++ b/src/common/GRAPHIC/GUI/FONTS/FONTS.pro @@ -1,10 +1,8 @@ -TEMPLATE = subdirs -SUBDIRS += ./FONTS_STM32F4.pro \ - ./FONTS_SIMULATOR.pro +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = fonts + +SOURCES += \ + fonts8pts.c - - - - - diff --git a/src/common/GRAPHIC/GUI/FONTS/FONTS_SIMULATOR.pro b/src/common/GRAPHIC/GUI/FONTS/FONTS_SIMULATOR.pro deleted file mode 100644 --- a/src/common/GRAPHIC/GUI/FONTS/FONTS_SIMULATOR.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = fonts - -SOURCES += \ - fonts8pts.c - -UCMODEL=simulator - diff --git a/src/common/GRAPHIC/GUI/FONTS/FONTS_STM32F4.pro b/src/common/GRAPHIC/GUI/FONTS/FONTS_STM32F4.pro deleted file mode 100644 --- a/src/common/GRAPHIC/GUI/FONTS/FONTS_STM32F4.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = fonts - -SOURCES += \ - fonts8pts.c - -UCMODEL=stm32f4 - diff --git a/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.pro b/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.pro --- a/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.pro +++ b/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.pro @@ -1,5 +1,7 @@ -TEMPLATE = subdirs -SUBDIRS += ./Terminal_STM32F4.pro \ - ./Terminal_SIMULATOR.pro +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = terminal +SOURCES += \ + Terminal.c diff --git a/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal_SIMULATOR.pro b/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal_SIMULATOR.pro deleted file mode 100644 --- a/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal_SIMULATOR.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = terminal - -SOURCES += \ - Terminal.c - -UCMODEL=simulator - diff --git a/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal_STM32F4.pro b/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal_STM32F4.pro deleted file mode 100644 --- a/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal_STM32F4.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = terminal - -SOURCES += \ - Terminal.c - -UCMODEL=stm32f4 - diff --git a/src/common/GRAPHIC/TC_CONTROLERS/ADS7843/ADS7843.pro b/src/common/GRAPHIC/TC_CONTROLERS/ADS7843/ADS7843.pro --- a/src/common/GRAPHIC/TC_CONTROLERS/ADS7843/ADS7843.pro +++ b/src/common/GRAPHIC/TC_CONTROLERS/ADS7843/ADS7843.pro @@ -1,5 +1,9 @@ -TEMPLATE = subdirs -CONFIG += ordered +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = ADS7843 -SUBDIRS += ./ADS7843_STM32F4.pro \ - ./ADS7843_SIMULATOR.pro +SOURCES += \ + ADS7843.c + + + diff --git a/src/common/GRAPHIC/TC_CONTROLERS/ADS7843/ADS7843_SIMULATOR.pro b/src/common/GRAPHIC/TC_CONTROLERS/ADS7843/ADS7843_SIMULATOR.pro deleted file mode 100644 --- a/src/common/GRAPHIC/TC_CONTROLERS/ADS7843/ADS7843_SIMULATOR.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = ADS7843 - -SOURCES += \ - ADS7843.c - -UCMODEL=simulator - - diff --git a/src/common/GRAPHIC/TC_CONTROLERS/ADS7843/ADS7843_STM32F4.pro b/src/common/GRAPHIC/TC_CONTROLERS/ADS7843/ADS7843_STM32F4.pro deleted file mode 100644 --- a/src/common/GRAPHIC/TC_CONTROLERS/ADS7843/ADS7843_STM32F4.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = ADS7843 - -SOURCES += \ - ADS7843.c - -DEFINES -= __OPTIMIZED_MATH - -UCMODEL=stm32f4 - - diff --git a/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811.pro b/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811.pro --- a/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811.pro +++ b/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811.pro @@ -1,5 +1,9 @@ -TEMPLATE = subdirs -CONFIG += ordered +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = STMPE811 -SUBDIRS += ./STMPE811_STM32F4.pro \ - ./STMPE811_SIMULATOR.pro +SOURCES += \ + STMPE811.c + + + diff --git a/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811_SIMULATOR.pro b/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811_SIMULATOR.pro deleted file mode 100644 --- a/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811_SIMULATOR.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = STMPE811 - -SOURCES += \ - STMPE811.c - -UCMODEL=simulator - - diff --git a/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811_STM32F4.pro b/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811_STM32F4.pro deleted file mode 100644 --- a/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811_STM32F4.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = STMPE811 - -SOURCES += \ - STMPE811.c - -DEFINES -= __OPTIMIZED_MATH - -UCMODEL=stm32f4 - - diff --git a/src/common/POWER/ina226/ina226.pro b/src/common/POWER/ina226/ina226.pro --- a/src/common/POWER/ina226/ina226.pro +++ b/src/common/POWER/ina226/ina226.pro @@ -1,5 +1,10 @@ -TEMPLATE = subdirs -CONFIG += ordered +TEMPLATE = lib +CONFIG += libuc2lib +TARGET = ina226 -SUBDIRS += ./ina226_STM32F4.pro \ - ./ina226_SIMULATOR.pro +SOURCES += ina226.c + + +HEADERS += \ + ../../../../include/POWER/ina226.h + diff --git a/src/common/POWER/ina226/ina226_SIMULATOR.pro b/src/common/POWER/ina226/ina226_SIMULATOR.pro deleted file mode 100644 --- a/src/common/POWER/ina226/ina226_SIMULATOR.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = ina226 - -SOURCES += ina226.c - -UCMODEL=simulator - -HEADERS += \ - ../../../../include/POWER/ina226.h - diff --git a/src/common/POWER/ina226/ina226_STM32F4.pro b/src/common/POWER/ina226/ina226_STM32F4.pro deleted file mode 100644 --- a/src/common/POWER/ina226/ina226_STM32F4.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -TARGET = ina226 - -SOURCES += ina226.c - -UCMODEL=stm32f4 - -HEADERS += \ - ../../../../include/POWER/ina226.h - diff --git a/src/common/Threading/Threading.pro b/src/common/Threading/Threading.pro --- a/src/common/Threading/Threading.pro +++ b/src/common/Threading/Threading.pro @@ -1,9 +1,8 @@ -TEMPLATE = subdirs -CONFIG += ordered +TEMPLATE = lib +CONFIG += libuc2lib +OBJECTS_DIR = obj -SUBDIRS += ./Threading_STM32F4.pro \ - ./Threading_SIMULATOR.pro +TARGET=Threading +SOURCES += thread.c - - diff --git a/src/common/Threading/Threading_SIMULATOR.pro b/src/common/Threading/Threading_SIMULATOR.pro deleted file mode 100644 --- a/src/common/Threading/Threading_SIMULATOR.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -OBJECTS_DIR = obj - -TARGET=Threading -SOURCES += thread.c - -UCMODEL=simulator - diff --git a/src/common/Threading/Threading_STM32F4.pro b/src/common/Threading/Threading_STM32F4.pro deleted file mode 100644 --- a/src/common/Threading/Threading_STM32F4.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = lib -CONFIG += libuc2lib -OBJECTS_DIR = obj - -TARGET=Threading -SOURCES += thread.c - -UCMODEL=stm32f4 - - - diff --git a/src/lib.pro b/src/lib.pro --- a/src/lib.pro +++ b/src/lib.pro @@ -1,17 +1,13 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += stm32f4 - +!isEmpty( UCMODEL ) { + contains( UCMODEL, stm32f4 ){ + SUBDIRS += stm32f4 + } + contains( UCMODEL, simulator ){ + SUBDIRS += simulator + } +} SUBDIRS += common -SUBDIRS += simulator - -headers.files = includes/*.h \ - includes/GRAPHIC/CONTROLERS/*.h \ - includes/GRAPHIC/TC_CONTROLERS/*.h \ - includes/GRAPHIC/GUI/FONTS/*.h \ - includes/GRAPHIC/GUI/Widgets/*.h - -headers.path = $$[QT_INSTALL_HEADERS] -INSTALLS += headers diff --git a/src/simulator/simulator.pro b/src/simulator/simulator.pro --- a/src/simulator/simulator.pro +++ b/src/simulator/simulator.pro @@ -1,3 +1,5 @@ +contains(UCMODEL,simulator) +{ TEMPLATE = subdirs CONFIG += ordered SUBDIRS = CORE/core.pro \ @@ -9,6 +11,4 @@ SUBDIRS = CORE/core.pro \ SDCARD \ SDLCD - - - +} diff --git a/src/stm32f4/stm32f4.pro b/src/stm32f4/stm32f4.pro --- a/src/stm32f4/stm32f4.pro +++ b/src/stm32f4/stm32f4.pro @@ -1,6 +1,7 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS = CORE/core.pro \ + +SUBDIRS = CORE/core.pro \ CPU/cpu.pro \ GPIO/gpio.pro \ UART/uart.pro \ @@ -9,5 +10,4 @@ SUBDIRS = CORE/core.pro \ SDCARD-SDIO/sdcard-sdio.pro -