diff --git a/Doxyfile b/Doxyfile --- a/Doxyfile +++ b/Doxyfile @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = /opt/libuc2/Doc/doxygen +OUTPUT_DIRECTORY = doc/doxygen # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -337,7 +337,7 @@ INLINE_SIMPLE_STRUCTS = NO # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. -TYPEDEF_HIDES_STRUCT = NO +TYPEDEF_HIDES_STRUCT = YES # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. @@ -375,7 +375,7 @@ LOOKUP_CACHE_SIZE = 0 # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = NO +EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. @@ -677,7 +677,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = /opt/libuc2 +INPUT = include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -1621,7 +1621,7 @@ INCLUDE_FILE_PATTERNS = # undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = +PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. @@ -1687,7 +1687,7 @@ PERL_PATH = /usr/bin/perl # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. -CLASS_DIAGRAMS = YES +CLASS_DIAGRAMS = NO # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see @@ -1709,7 +1709,7 @@ HIDE_UNDOC_RELATIONS = YES # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) -HAVE_DOT = NO +HAVE_DOT = YES # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will @@ -1717,7 +1717,7 @@ HAVE_DOT = NO # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. -DOT_NUM_THREADS = 0 +DOT_NUM_THREADS = 4 # By default doxygen will use the Helvetica font for all dot files that # doxygen generates. When you want a differently looking font you can specify @@ -1798,7 +1798,7 @@ INCLUDED_BY_GRAPH = YES # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. -CALL_GRAPH = NO +CALL_GRAPH = YES # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function @@ -1806,7 +1806,7 @@ CALL_GRAPH = NO # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. -CALLER_GRAPH = NO +CALLER_GRAPH = YES # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. @@ -1835,7 +1835,7 @@ DOT_IMAGE_FORMAT = png # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible. Older versions of IE do not have SVG support. -INTERACTIVE_SVG = NO +INTERACTIVE_SVG = YES # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. diff --git a/include/24LC0X.h b/include/24LC0X.h deleted file mode 100644 --- a/include/24LC0X.h +++ /dev/null @@ -1,56 +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 B24LC0X_H -#define B24LC0X_H - -#include -#include - -typedef struct eeprom24lc0xDev -{ - i2c_t iicdev; - unsigned char devAddress; - unsigned char size; -}eeprom24lc0xDev; - - - -extern void eeprom24lc0xopen(eeprom24lc0xDev* dev,i2c_t iicdev,unsigned char A0_A1_A2_val,unsigned int size); - -extern void eeprom24lc0xpagewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page); -extern void eeprom24lc0xpageread(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page); -extern void eeprom24lc0xbytewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char data); -extern unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev* dev,unsigned char address); -extern void eeprom24lc0xreadn(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count); -extern void eeprom24lc0xwriten(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count); - - - - -#endif - - - - - - - diff --git a/include/ADC/ads1278.h b/include/ADC/ads1278.h new file mode 100644 --- /dev/null +++ b/include/ADC/ads1278.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------------------------ +#-- 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@gmail.com +#-------------------------------------------------------------------------------*/ +#ifndef ADS1278_H +#define ADS1278_H +#include + +typedef void (*set_clkdiv_t)(int val); +typedef void (*set_sync_t)(int val); +typedef void (*set_mode0_t)(int val); +typedef void (*set_mode1_t)(int val); +typedef void (*set_fsync_t)(int val); +typedef int (*ready_t)(); + +struct ads1278Regs +{ + sspDev SSP_device; + set_clkdiv_t set_clkdiv; + set_sync_t set_sync; + set_mode0_t set_mode0; + set_mode1_t set_mode1; + set_fsync_t set_fsync; + ready_t ready; +}; + +typedef struct ads1278Regs ads1278Dev; + +void ads1278open(ads1278Dev* codec,sspDev dev); +void ads1278sample(ads1278Dev* dev); +void ads1278readresult(ads1278Dev* dev,unsigned int* CH1,unsigned int* CH2,unsigned int* CH3,unsigned int* CH4,unsigned int* CH5,unsigned int* CH6,unsigned int* CH7,unsigned int* CH8); + +extern void bsp_ads1278_Sample(); +extern int bsp_ads1278_Ready(); +extern void bsp_ads1278_Synch(); + +#endif + + + + + + + + + + + + + + + + + + diff --git a/include/AUDIO/CS43L22.h b/include/AUDIO/CS43L22.h new file mode 100644 --- /dev/null +++ b/include/AUDIO/CS43L22.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@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef CS43L22_H +#define CS43L22_H + +#include + +typedef struct CS43L22_t +{ + i2c_t i2cdev; + uint8_t devAddress; +}CS43L22_t; + +extern int cs43l22open(CS43L22_t* dev,i2c_t i2cdev,uint8_t A0); +extern uint8_t cs43l22getID(CS43L22_t* dev); + +#define CS43L22_I2C_ADDRESS 0x4a + + +#define CS43L22_MAP_ID 1 +#define CS43L22_MAP_Power_Ctl_1 2 +#define CS43L22_MAP_Power_Ctl_2 4 +#define CS43L22_MAP_Clocking_Ctl 5 +#define CS43L22_MAP_Interface_Ctl_1 6 +#define CS43L22_MAP_Interface_Ctl_2 7 +#define CS43L22_MAP_Passthrough_A 8 +#define CS43L22_MAP_Passthrough_B 9 +#define CS43L22_MAP_Analog_ZC_SR 0xA +#define CS43L22_MAP_Passthrough 0xC +#define CS43L22_MAP_Playback_Ctl_1 0xD +#define CS43L22_MAP_Misc_Ctl 0xE +#define CS43L22_MAP_Playback_Ctl_2 0xF +#define CS43L22_MAP_Passthrough_A_Vol 0x14 +#define CS43L22_MAP_Passthrough_B_Vol 0x15 +#define CS43L22_MAP_PCMA_Vol 0x1A +#define CS43L22_MAP_PCMB_Vol 0x1B +#define CS43L22_MAP_BEEP_Freq 0x1C +#define CS43L22_MAP_BEEP_Vol 0x1d +#define CS43L22_MAP_BEEP_Tone_Cfg 0x1E +#define CS43L22_MAP_Tone_Ctl 0x1F +#define CS43L22_MAP_Master_A_Vol 0x20 +#define CS43L22_MAP_Master_B_Vol 0x21 +#define CS43L22_MAP_Headphone_A_Vol 0x22 +#define CS43L22_MAP_Headphone_B_Vol 0x23 +#define CS43L22_MAP_Speaker_A_Vol 0x24 +#define CS43L22_MAP_Speaker_B_Vol 0x25 +#define CS43L22_MAP_Channel_Mixer 0x26 +#define CS43L22_MAP_Limit_Ctl_1 0x27 +#define CS43L22_MAP_Limit Ctl_2 0x28 +#define CS43L22_MAP_Limiter_Attack 0x29 +#define CS43L22_MAP_Overflow_And_Clock_Status 0x2E +#define CS43L22_MAP_Battery_Compensation 0x2F +#define CS43L22_MAP_VP_Battery_Level 0x30 +#define CS43L22_MAP_Speaker_Status 0x31 +#define CS43L22_MAP_Temperature_Monitor_Control 0x32 +#define CS43L22_MAP_Thermal_Foldback 0x33 +#define CS43L22_MAP_Charge_Pump_Frequency 0x34 + + +#endif + + + + + + + diff --git a/include/AUDIO/VS10XX.h b/include/AUDIO/VS10XX.h new file mode 100644 --- /dev/null +++ b/include/AUDIO/VS10XX.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 VS10XX_H +#define VS10XX_H +#include + +#define VSMODE 0 +#define VSSTATUS 1 +#define VSBASS 2 +#define VSCLOCKF 3 +#define VSDECODE_TIME 4 +#define VSAUDATA 5 +#define VSWRAM 6 +#define VSWRAMADDR 7 +#define VSHDAT0 8 +#define VSHDAT1 9 +#define VSAIADDR 0xA +#define VSVOL 0xB +#define VSAICTRL0 0xC +#define VSAICTRL1 0xD +#define VSAICTRL2 0xE +#define VSAICTRL3 0xF + +// TODO real generic VS10XX driver + plugin and patch loader + +typedef enum VS10XXVER_en +{ + UNKNOWN, + VS1001, + VS1011, + VS1002, + VS1003, + VS1053, + VS1033, + VS1103 +}VS10XXVER_en; + +typedef struct vs10XXDev +{ + spi_t SPIdev; + void (*setxCS)(char); + void (*setxRST)(char); + void (*setxDCS)(char); + int (*getDREQ)(); + VS10XXVER_en VERSION; +}vs10XXDev; + + +void vs10XXopen(vs10XXDev* codec,spi_t dev, void (*setxCS)(char),void (*setxRST)(char),void (*setxDCS)(char),int (*getDREQ)()); +void vs10XXsoftreset(vs10XXDev* dev); +int vs10XXcmdread(vs10XXDev* dev,char address); +void vs10XXcmdwrite(vs10XXDev* dev,char address,int value); +void vs10XXstream32bytes(vs10XXDev* dev,char* buffer); +void vs10XXsetCansel(vs10XXDev* dev); +int vs10XXcanselAccepted(vs10XXDev* dev); +void vs10XXsoftReset(vs10XXDev* dev); +//extern void vs10XXclearXCS(); +//extern void vs10XXsetXCS(); +//extern int vs10XXDREQ(); + +#endif //VS10XX_H + + + + + + + + + + + + + + + + + + diff --git a/include/CS43L22.h b/include/CS43L22.h deleted file mode 100644 --- a/include/CS43L22.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@gmail.com --------------------------------------------------------------------------------*/ -#ifndef CS43L22_H -#define CS43L22_H - -#include -#include - -typedef struct CS43L22_t -{ - i2c_t i2cdev; - uint8_t devAddress; -}CS43L22_t; - -extern int cs43l22open(CS43L22_t* dev,i2c_t i2cdev,uint8_t A0); -extern uint8_t cs43l22getID(CS43L22_t* dev); - -#define CS43L22_I2C_ADDRESS 0x4a - - -#define CS43L22_MAP_ID 1 -#define CS43L22_MAP_Power_Ctl_1 2 -#define CS43L22_MAP_Power_Ctl_2 4 -#define CS43L22_MAP_Clocking_Ctl 5 -#define CS43L22_MAP_Interface_Ctl_1 6 -#define CS43L22_MAP_Interface_Ctl_2 7 -#define CS43L22_MAP_Passthrough_A 8 -#define CS43L22_MAP_Passthrough_B 9 -#define CS43L22_MAP_Analog_ZC_SR 0xA -#define CS43L22_MAP_Passthrough 0xC -#define CS43L22_MAP_Playback_Ctl_1 0xD -#define CS43L22_MAP_Misc_Ctl 0xE -#define CS43L22_MAP_Playback_Ctl_2 0xF -#define CS43L22_MAP_Passthrough_A_Vol 0x14 -#define CS43L22_MAP_Passthrough_B_Vol 0x15 -#define CS43L22_MAP_PCMA_Vol 0x1A -#define CS43L22_MAP_PCMB_Vol 0x1B -#define CS43L22_MAP_BEEP_Freq 0x1C -#define CS43L22_MAP_BEEP_Vol 0x1d -#define CS43L22_MAP_BEEP_Tone_Cfg 0x1E -#define CS43L22_MAP_Tone_Ctl 0x1F -#define CS43L22_MAP_Master_A_Vol 0x20 -#define CS43L22_MAP_Master_B_Vol 0x21 -#define CS43L22_MAP_Headphone_A_Vol 0x22 -#define CS43L22_MAP_Headphone_B_Vol 0x23 -#define CS43L22_MAP_Speaker_A_Vol 0x24 -#define CS43L22_MAP_Speaker_B_Vol 0x25 -#define CS43L22_MAP_Channel_Mixer 0x26 -#define CS43L22_MAP_Limit_Ctl_1 0x27 -#define CS43L22_MAP_Limit Ctl_2 0x28 -#define CS43L22_MAP_Limiter_Attack 0x29 -#define CS43L22_MAP_Overflow_And_Clock_Status 0x2E -#define CS43L22_MAP_Battery_Compensation 0x2F -#define CS43L22_MAP_VP_Battery_Level 0x30 -#define CS43L22_MAP_Speaker_Status 0x31 -#define CS43L22_MAP_Temperature_Monitor_Control 0x32 -#define CS43L22_MAP_Thermal_Foldback 0x33 -#define CS43L22_MAP_Charge_Pump_Frequency 0x34 - - -#endif - - - - - - - diff --git a/include/EEPROMS/24LC0X.h b/include/EEPROMS/24LC0X.h new file mode 100644 --- /dev/null +++ b/include/EEPROMS/24LC0X.h @@ -0,0 +1,55 @@ +/*------------------------------------------------------------------------------ +-- 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 B24LC0X_H +#define B24LC0X_H + +#include + +typedef struct eeprom24lc0xDev +{ + i2c_t iicdev; + unsigned char devAddress; + unsigned char size; +}eeprom24lc0xDev; + + + +extern void eeprom24lc0xopen(eeprom24lc0xDev* dev,i2c_t iicdev,unsigned char A0_A1_A2_val,unsigned int size); + +extern void eeprom24lc0xpagewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page); +extern void eeprom24lc0xpageread(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page); +extern void eeprom24lc0xbytewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char data); +extern unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev* dev,unsigned char address); +extern void eeprom24lc0xreadn(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count); +extern void eeprom24lc0xwriten(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count); + + + + +#endif + + + + + + + diff --git a/include/EEPROMS/N25Q128.h b/include/EEPROMS/N25Q128.h new file mode 100644 --- /dev/null +++ b/include/EEPROMS/N25Q128.h @@ -0,0 +1,73 @@ +/*------------------------------------------------------------------------------ +-- 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 +-------------------------------------------------------------------------------*/ +#ifndef N25Q128_H +#define N25Q128_H + +#include + +typedef struct eepromN25Q128Dev +{ + spi_t spidev; + void (*select)(int sel); + void (*writeprotect)(int wp); + void (*holdreset)(int hr); +}eepromN25Q128Dev; + +#define N25Q128_PAGE_SZ 256 +#define N25Q128_CAPACITY_IN_BYTES (1024*1024*16) /*16MB*/ + +#define N25Q128_READID 0x9E +#define N25Q128_READ 0x03 +#define N25Q128_FASTREAD 0x0B +#define N25Q128_DOFR 0x3B +#define N25Q128_DIOFR 0xBB +#define N25Q128_QOFR 0x6B +#define N25Q128_QIOFR 0xEB +#define N25Q128_ROTP 0x4B +#define N25Q128_WREN 0x06 +#define N25Q128_WRDI 0x04 +#define N25Q128_PP 0x02 + + + + + +extern void eepromN25Q128open(eepromN25Q128Dev* dev,spi_t spidev,void (*select)(int sel),void (*writeprotect)(int wp),void (*holdreset)(int hr)); +extern void eepromN25Q128pagewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page); +extern void eepromN25Q128pageread(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page); +extern void eepromN25Q128bytewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char data); +extern unsigned char eepromN25Q128byteread(eepromN25Q128Dev* dev,uint32_t address); +extern void eepromN25Q128readn(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count); +extern void eepromN25Q128writen(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count); +extern void eepromN25Q128enablewrite(eepromN25Q128Dev* dev); + + + + +#endif + + + + + + + diff --git a/include/FLASH/sdcard-sdio.h b/include/FLASH/sdcard-sdio.h new file mode 100644 --- /dev/null +++ b/include/FLASH/sdcard-sdio.h @@ -0,0 +1,62 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef SDCARD_SDIO_H +#define SDCARD_SDIO_H +#include + +extern void sdcardsdiomake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)); +extern void sdcardsdiomakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected); + + +#endif //SDCARD_SDIO_H + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/FLASH/sdcard-spi.h b/include/FLASH/sdcard-spi.h new file mode 100644 --- /dev/null +++ b/include/FLASH/sdcard-spi.h @@ -0,0 +1,63 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef SDCARD_SPI_H +#define SDCARD_SPI_H +#include + + +extern void sdcardspimake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)); +extern void sdcardspimakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected); + + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/FLASH/sdcard.h b/include/FLASH/sdcard.h new file mode 100644 --- /dev/null +++ b/include/FLASH/sdcard.h @@ -0,0 +1,104 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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 SDCARD_H +#define SDCARD_H +#include + +/* MMC/SD command */ +#define CMD0 (0) /* GO_IDLE_STATE */ +#define CMD1 (1) /* SEND_OP_COND (MMC) */ +#define ACMD41 (0x80+41) /* SEND_OP_COND (SDC) */ +#define CMD8 (8) /* SEND_IF_COND */ +#define CMD9 (9) /* SEND_CSD */ +#define CMD10 (10) /* SEND_CID */ +#define CMD12 (12) /* STOP_TRANSMISSION */ +#define ACMD13 (0x80+13) /* SD_STATUS (SDC) */ +#define CMD16 (16) /* SET_BLOCKLEN */ +#define CMD17 (17) /* READ_SINGLE_BLOCK */ +#define CMD18 (18) /* READ_MULTIPLE_BLOCK */ +#define CMD23 (23) /* SET_BLOCK_COUNT (MMC) */ +#define ACMD23 (0x80+23) /* SET_WR_BLK_ERASE_COUNT (SDC) */ +#define CMD24 (24) /* WRITE_BLOCK */ +#define CMD25 (25) /* WRITE_MULTIPLE_BLOCK */ +#define CMD32 (32) /* ERASE_ER_BLK_START */ +#define CMD33 (33) /* ERASE_ER_BLK_END */ +#define CMD38 (38) /* ERASE */ +#define CMD55 (55) /* APP_CMD */ +#define CMD58 (58) /* READ_OCR */ + +/* Card type flags (CardType) */ +#define CT_MMC 0x01 /* MMC ver 3 */ +#define CT_SD1 0x02 /* SD ver 1 */ +#define CT_SD2 0x04 /* SD ver 2 */ +#define CT_SDC (CT_SD1|CT_SD2) /* SD */ +#define CT_BLOCK 0x08 /* Block addressing */ + +struct sdcard_str +{ + UHANDLE phy; + int (*rcvr_mmc) (UHANDLE phy,char *buff,uint32_t bc); + int (*xmit_mmc) (UHANDLE phy,const char *buff,uint32_t bc); + int (*setspeed) (UHANDLE phy,uint32_t speed); + uint32_t (*getspeed) (UHANDLE phy); + DSTATUS Stat; + char CardType; +}; + +typedef volatile struct sdcard_str sdcardDev; + +//extern void sdcardmake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)); +//extern void sdcardmakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected); + + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/FS/blkdevice.h b/include/FS/blkdevice.h new file mode 100644 --- /dev/null +++ b/include/FS/blkdevice.h @@ -0,0 +1,128 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef BLKDEVICE_H +#define BLKDEVICE_H +#include +/* Disk Status Bits (DSTATUS) */ + +#define STA_NOINIT 0x01 /* Drive not initialized */ +#define STA_NODISK 0x02 /* No medium in the drive */ +#define STA_PROTECT 0x04 /* Write protected */ + + +/* Command code for disk_ioctrl fucntion */ +/* Generic ioctl command (defined for FatFs) */ +#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */ +#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */ +#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ +#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */ +#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */ + +/* Generic ioctl command */ +#define CTRL_POWER 5 /* Get/Set power status */ +#define CTRL_LOCK 6 /* Lock/Unlock media removal */ +#define CTRL_EJECT 7 /* Eject media */ + +/* MMC/SDC specific ioctl command */ +#define MMC_GET_TYPE 10 /* Get card type */ +#define MMC_GET_CSD 11 /* Get CSD */ +#define MMC_GET_CID 12 /* Get CID */ +#define MMC_GET_OCR 13 /* Get OCR */ +#define MMC_GET_SDSTAT 14 /* Get SD status */ + +/* ATA/CF specific ioctl command */ +#define ATA_GET_REV 20 /* Get F/W revision */ +#define ATA_GET_MODEL 21 /* Get model name */ +#define ATA_GET_SN 22 /* Get serial number */ + +/* NAND specific ioctl command */ +#define NAND_FORMAT 30 /* Create physical format */ + +/* Status of Disk Functions */ +typedef unsigned char DSTATUS; + +/* Results of Disk Functions */ +typedef enum { + RES_OK = 0, /* 0: Successful */ + RES_ERROR, /* 1: R/W Error */ + RES_WRPRT, /* 2: Write Protected */ + RES_NOTRDY, /* 3: Not Ready */ + RES_PARERR /* 4: Invalid Parameter */ +} DRESULT; + +typedef volatile struct blkdevice* blkdeviceptr; + +typedef void (*blkdevselect_t)(char) ; +typedef void (*blkdevpower_t)(char) ; +typedef char (*blkdevdetect_t)() ; +typedef char (*blkdevwriteprotected_t)() ; +typedef DRESULT (*blkdevwrite_t)(blkdeviceptr _this,const char *buff,unsigned long sector,char count) ; +typedef DRESULT (*blkdevread_t)(blkdeviceptr _this,char *buff,unsigned long sector,char count) ; +typedef DRESULT (*blkdevioctl_t)(blkdeviceptr _this,char ctrl,void *buff) ; +typedef DSTATUS (*blkdevinitialize_t)(blkdeviceptr _this) ; +typedef DSTATUS (*blkdevstatus_t) (blkdeviceptr _this) ; + +typedef struct blkdevice +{ + UHANDLE phy; + unsigned int size; + unsigned int MaxSpeed; + unsigned char Version; + blkdevselect_t select; + blkdevpower_t power; + blkdevdetect_t detect; + blkdevwriteprotected_t writeprotected; + blkdevwrite_t write; + blkdevread_t read; + blkdevioctl_t ioctl; + blkdevinitialize_t initialize; + blkdevstatus_t status; +}blkdevice; + + + + + + +#endif + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/FS/fat32.h b/include/FS/fat32.h new file mode 100644 --- /dev/null +++ b/include/FS/fat32.h @@ -0,0 +1,194 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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 FAT32_H +#define FAT32_H +#include +#include +#include +//#include +/*BPB (Boot Sector) Offsets */ + +#define BS_jmpBootoff 0 +#define BS_OEMNameoff 3 +#define BPB_BytsPerSecoff 11 +#define BPB_SecPerClusoff 13 +#define BPB_RsvdSecCntoff 14 +#define BPB_NumFATsoff 16 +#define BPB_RootEntCntoff 17 +#define BPB_TotSec16off 19 +#define BPB_Mediaoff 21 +#define BPB_FATSz16off 22 +#define BPB_SecPerTrkoff 24 +#define BPB_NumHeadsoff 26 +#define BPB_HiddSecoff 28 +#define BPB_TotSec32off 32 +/*FAT16*/ +#define BS_DrvNumFAT16off 36 +#define BS_Reserved1FAT16off 37 +#define BS_BootSigFAT16off 38 +#define BS_VolIDFAT16off 39 +#define BS_VolLabFAT16off 43 +#define BS_FilSysTypeFAT16off 54 +/*FAT32*/ +#define BPB_FATSz32off 36 +#define BPB_ExtFlagsoff 40 +#define BPB_FSVeroff 42 +#define BPB_RootClusoff 44 +#define BPB_FSInfooff 48 +#define BPB_BkBootSecoff 50 +#define BPB_Reservedoff 52 +#define BS_DrvNumFAT32off 64 +#define BS_Reserved1FAT32off 65 +#define BS_BootSigFAT32off 66 +#define BS_VolIDFAT32off 67 +#define BS_VolLabFAT32off 71 +#define BS_FilSysTypeFAT32off 82 + + +#define DIR_Nameoff 0 +#define DIR_Attroff 0xb +#define DIR_FstClusHIoff 0x14 +#define DIR_FstClusLOoff 0x1A +#define DIR_FileSizeoff 0x1c +#define DIR_CrtTimeTenthoff 13 +#define DIR_CrtTimeoff 14 +#define DIR_CrtDateoff 16 +#define DIR_LstAccDateoff 18 +#define DIR_WrtTimeoff 22 +#define DIR_WrtDateoff 24 + + + +#define FATBadpart 1 +#define FATBabArg 2 +#define FATReadErr 3 +#define FATnoErr 0 + +/* + TODO : + intergrate a per BLKDEV or per partition buffer. +*/ +typedef struct FAT32fs +{ + uint16_t BPB_BytsPerSec; + uint16_t BPB_RsvdSecCnt; + uint32_t BPB_FATSz32; + uint32_t BPB_RootClus; + uint32_t fat_begin_lba; + uint32_t cluster_begin_lba; + uint8_t BPB_SecPerClus; + uint8_t BPB_NumFATs; + char valide; + dikpartition* part; +}FAT32fs; + + +#define castUI64(val) ((uint64_t)(val)) +#define castUI32(val) ((uint32_t)(val)) +#define castUI16(val) ((uint16_t)(val)) +#define castUI8(val) ((uint8_t)(val)) + +#define castI64(val) ((int64_t)(val)) +#define castI32(val) ((int32_t)(val)) +#define castI16(val) ((int16_t)(val)) +#define castI8(val) ((int8_t)(val)) + +/* + TODO : + Should add global function for casting with endianness care. + have a look at REV, REV16, REVSH, and RBIT ARMV7m asm +*/ + +#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ + #define fat32Ui8_2_Ui32(table,lsBindex) ((uint32_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint32_t)table[lsBindex+1])<<8))+(0xFF0000&(((uint32_t)table[lsBindex+2])<<16))+(0xFF000000&(((uint32_t)table[lsBindex+3])<<24)))) + #define fat32Ui8_2_Ui16(table,lsBindex) ((uint16_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint16_t)table[lsBindex+1])<<8)))) + #define fat32extract16b(table, LSBOffset) (uint16_t)(( (uint16_t) ((uint8_t)table[(LSBOffset)]) ) + (uint16_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )) + #define fat32extract32b(table, LSBOffset) (uint32_t)(( (uint32_t) ((uint8_t)table[(LSBOffset)]) ) + (uint32_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+2]) << 16 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+3]) << 24 )) +#else + #define fat32Ui8_2_Ui32(table,lsBindex) ((uint32_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint32_t)table[lsBindex+1])<<8))+(0xFF0000&(((uint32_t)table[lsBindex+2])<<16))+(0xFF000000&(((uint32_t)table[lsBindex+3])<<24)))) + #define fat32Ui8_2_Ui16(table,lsBindex) ((uint16_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint16_t)table[lsBindex+1])<<8)))) + #define fat32extract16b(table, LSBOffset) (uint16_t)(( (uint16_t) ((uint8_t)table[(LSBOffset)]) ) + (uint16_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )) + #define fat32extract32b(table, LSBOffset) (uint32_t)(( (uint32_t) ((uint8_t)table[(LSBOffset)]) ) + (uint32_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+2]) << 16 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+3]) << 24 )) +#endif + + +/* Get the first sector lba of given cluster number*/ +#define clusterlba(fs,cluster_number) ((uint32_t)fs->cluster_begin_lba + (((uint32_t)cluster_number) - (2)) * (uint32_t)fs->BPB_SecPerClus) + +//#define fat32clusterinfatsect(fs,cluster_number) ((((uint32_t)(cluster_number))>>6) + fs->fat_begin_lba) +#define fat32clusterinfatsect(fs,cluster_number) ((((uint32_t)(cluster_number))>>7) + fs->fat_begin_lba) +#define fat32clusterinfatoff(cluster_number) (((cluster_number)&0x7F)*4) + +/*Get cluster index in FAT Table from sector address*/ +#define fat32masksectorlba(sectorlba,fs) (sectorlba)//(sectorlba & (castUI32(-1)^castUI32(fs->BPB_SecPerClus-1))) +#define fat32sectorlbatoclusternum(fs,sectorlba) (((fat32masksectorlba(castUI32(sectorlba),fs) -(castUI32(fs->cluster_begin_lba)))/castUI32(fs->BPB_SecPerClus))+castUI32(2)) + + +#ifdef FAT32_PRIVATE +#define fat32sectorreadout(fs,fatsec) \ + if((lastSecAddrs!=(fatsec)) || (lastFATFS!=(fs))) /*Check if sector already buffered*/ \ + {\ + if((fs)->part->phy->read((fs)->part->phy,fat32buff,(fatsec),1)!=RES_OK) \ + {\ + return DIRENT_ReadErr;\ + }\ + }\ + lastSecAddrs=(fatsec);\ + lastFATFS=(fs); +#endif + +extern int fat32open(FAT32fs* fs,dikpartition* part); +extern int fat32mkdirent(FAT32fs* fs,ucdirent* dirent); +extern int fat32getVolName(FAT32fs* fs,char* Name); +extern int fat32getrootfirstent(ucdirent* entry); +extern int fat32nextdirent(ucdirent* entry); +extern int fat32nextsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t* nextsector_lba); +extern int fat32prevsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t *nextsector_lba); +extern int fat32prevsectorlba2(FAT32fs* fs,ucdirent* entry,uint32_t lastsector_lba,uint32_t *nextsector_lba); +extern uint32_t fat32getdirentlba(ucdirent* entry); +extern int fat32getdirentname(ucdirent* entry,char* nameBuffer); + +#endif + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/FS/libucfs.h b/include/FS/libucfs.h new file mode 100644 --- /dev/null +++ b/include/FS/libucfs.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef FS_H +#define FS_H +#include + +struct fs_str +{ + UHANDLE fat; +}; + +typedef struct fs_str filesys_t; + + + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/FS/mbr.h b/include/FS/mbr.h new file mode 100644 --- /dev/null +++ b/include/FS/mbr.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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 MBR_H +#define MBR_H +#include + +#define BootFlagoffset 0 +#define TypeCodeoffset 4 +#define LBABeginoffset 8 +#define NumOfSecoffset 12 + +#define MBRBadMbr 1 +#define MBRBabArg 2 +#define MBRReadErr 3 +#define MBRnoErr 0 + +#define isFat32(TypeCode) (((TypeCode)==0x0b)||((TypeCode)==0x0c)) + +typedef struct dikpartition +{ + char TypeCode; + char valide; + unsigned int LBABegin; + unsigned int NumOfSec; + blkdevice* phy; +}dikpartition; + + +int mbropen(blkdevice* phy,dikpartition* part,char partNum); + + +#endif + + + + + + + + + + + + + + + + + + + + diff --git a/include/FS/ucdirent.h b/include/FS/ucdirent.h new file mode 100644 --- /dev/null +++ b/include/FS/ucdirent.h @@ -0,0 +1,131 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef UCDIRENT_H +#define UCDIRENT_H +#include + + +#define ATTR_READ_ONLY 0x01 +#define ATTR_HIDDEN 0x02 +#define ATTR_SYSTEM 0x04 +#define ATTR_VOLUME_ID 0x08 +#define ATTR_DIRECTORY 0x10 +#define ATTR_ARCHIVE 0x20 +#define ATTR_LONGNAME 0x0F + +#define DIRENT_EndOfDir 1 +#define DIRENT_BabArg 2 +#define DIRENT_ReadErr 3 +#define DIRENT_LastSect 4 +#define DIRENT_BadSect 5 +#define DIRENT_noErr 0 + +typedef struct ucdirent* ucdirentptr; +typedef int (*getrootfirstent_t)(ucdirentptr entry); +typedef int (*nextdirent_t)(ucdirentptr entry); +typedef int (*getname_t)(ucdirentptr entry,char* name); + +typedef struct dirent +{ + unsigned char DIR_Name[16]; + unsigned char DIR_Attr; + unsigned char DIR_CrtTimeTenth; + unsigned short DIR_CrtTime; + unsigned short DIR_CrtDate; + unsigned short DIR_LstAccDate; + unsigned short DIR_FstClusHI; + unsigned short DIR_WrtTime; + unsigned short DIR_WrtDate; + unsigned short DIR_FstClustLO; + unsigned int DIR_FileSize; + unsigned int CurrentSec; + unsigned char Currententry; + UHANDLE fs; + getrootfirstent_t getrootfirstent; + nextdirent_t nextdirent; + getname_t getname; +}dirent; + +typedef struct ucdirent{ + uint8_t DIR_Name[16]; + uint8_t DIR_Attr; + uint8_t DIR_CrtTimeTenth; + uint16_t DIR_CrtTime; + uint16_t DIR_CrtDate; + uint16_t DIR_LstAccDate; + uint16_t DIR_FstClusHI; + uint16_t DIR_WrtTime; + uint16_t DIR_WrtDate; + uint16_t DIR_FstClustLO; + uint32_t DIR_FileSize; + uint32_t CurrentSec; + uint8_t Currententry; + UHANDLE fs; + getrootfirstent_t getrootfirstent; + nextdirent_t nextdirent; + getname_t getname; +}ucdirent; + + + +#define direntgetroot(dirent) (dirent).getrootfirstent(&dirent) +#define direntgetnext(dirent) (dirent).nextdirent(&dirent) + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/GRAPHIC/CONTROLERS/SDLCD.h b/include/GRAPHIC/CONTROLERS/SDLCD.h --- a/include/GRAPHIC/CONTROLERS/SDLCD.h +++ b/include/GRAPHIC/CONTROLERS/SDLCD.h @@ -22,7 +22,6 @@ #include #include -#include #define LCDILI9328 9328 diff --git a/include/GRAPHIC/CONTROLERS/genericLCD_Controler.h b/include/GRAPHIC/CONTROLERS/genericLCD_Controler.h --- a/include/GRAPHIC/CONTROLERS/genericLCD_Controler.h +++ b/include/GRAPHIC/CONTROLERS/genericLCD_Controler.h @@ -23,7 +23,6 @@ #define GENERICLCD_CONTROLER_H #include -#include #include diff --git a/include/GRAPHIC/CONTROLERS/ili9328.h b/include/GRAPHIC/CONTROLERS/ili9328.h --- a/include/GRAPHIC/CONTROLERS/ili9328.h +++ b/include/GRAPHIC/CONTROLERS/ili9328.h @@ -22,10 +22,7 @@ #ifndef ILI9328_H #define ILI9328_H -#include #include -#include -#include extern int ili9328init(struct LCD_t* LCD); extern void ili9328setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H); diff --git a/include/GRAPHIC/CONTROLERS/ssd2119.h b/include/GRAPHIC/CONTROLERS/ssd2119.h --- a/include/GRAPHIC/CONTROLERS/ssd2119.h +++ b/include/GRAPHIC/CONTROLERS/ssd2119.h @@ -22,10 +22,7 @@ #ifndef SSD2119_H #define SSD2119_H -#include #include -#include -#include extern int ssd2119init(struct LCD_t* LCD); extern void ssd2119setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H); diff --git a/include/GRAPHIC/GUI/Widgets/hexviewer.h b/include/GRAPHIC/GUI/Widgets/hexviewer.h new file mode 100644 --- /dev/null +++ b/include/GRAPHIC/GUI/Widgets/hexviewer.h @@ -0,0 +1,51 @@ +/*------------------------------------------------------------------------------ +#-- 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@gmail.com +#-------------------------------------------------------------------------------*/ +#ifndef HEXVIEWER_H +#define HEXVIEWER_H + + + + + +extern void hexviewershow(const char* table,unsigned int size,unsigned int offset); + + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/include/GRAPHIC/GUI/Widgets/terminal.h b/include/GRAPHIC/GUI/Widgets/terminal.h --- a/include/GRAPHIC/GUI/Widgets/terminal.h +++ b/include/GRAPHIC/GUI/Widgets/terminal.h @@ -21,11 +21,9 @@ -------------------------------------------------------------------------------*/ #ifndef TERMINAL_H #define TERMINAL_H -#include #include #include #include -#include typedef struct terminal_t { diff --git a/include/GRAPHIC/TC_CONTROLERS/ADS7843.h b/include/GRAPHIC/TC_CONTROLERS/ADS7843.h --- a/include/GRAPHIC/TC_CONTROLERS/ADS7843.h +++ b/include/GRAPHIC/TC_CONTROLERS/ADS7843.h @@ -22,10 +22,7 @@ #ifndef STMPE811_H #define STMPE811_H #include -#include #include -#include -#include #include typedef struct ADS7843_t diff --git a/include/GRAPHIC/TC_CONTROLERS/STMPE811.h b/include/GRAPHIC/TC_CONTROLERS/STMPE811.h --- a/include/GRAPHIC/TC_CONTROLERS/STMPE811.h +++ b/include/GRAPHIC/TC_CONTROLERS/STMPE811.h @@ -22,10 +22,7 @@ #ifndef STMPE811_H #define STMPE811_H #include -#include #include -#include -#include #include typedef struct STMPE811_t diff --git a/include/GRAPHIC/TC_CONTROLERS/genericTC_Controler.h b/include/GRAPHIC/TC_CONTROLERS/genericTC_Controler.h --- a/include/GRAPHIC/TC_CONTROLERS/genericTC_Controler.h +++ b/include/GRAPHIC/TC_CONTROLERS/genericTC_Controler.h @@ -23,7 +23,6 @@ #define GENERICTC_CONTROLER_H #include -#include #include diff --git a/include/N25Q128.h b/include/N25Q128.h deleted file mode 100644 --- a/include/N25Q128.h +++ /dev/null @@ -1,75 +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 --------------------------------------------------------------------------------*/ -#ifndef N25Q128_H -#define N25Q128_H - -#include -#include -#include - -typedef struct eepromN25Q128Dev -{ - spi_t spidev; - void (*select)(int sel); - void (*writeprotect)(int wp); - void (*holdreset)(int hr); -}eepromN25Q128Dev; - -#define N25Q128_PAGE_SZ 256 -#define N25Q128_CAPACITY_IN_BYTES (1024*1024*16) /*16MB*/ - -#define N25Q128_READID 0x9E -#define N25Q128_READ 0x03 -#define N25Q128_FASTREAD 0x0B -#define N25Q128_DOFR 0x3B -#define N25Q128_DIOFR 0xBB -#define N25Q128_QOFR 0x6B -#define N25Q128_QIOFR 0xEB -#define N25Q128_ROTP 0x4B -#define N25Q128_WREN 0x06 -#define N25Q128_WRDI 0x04 -#define N25Q128_PP 0x02 - - - - - -extern void eepromN25Q128open(eepromN25Q128Dev* dev,spi_t spidev,void (*select)(int sel),void (*writeprotect)(int wp),void (*holdreset)(int hr)); -extern void eepromN25Q128pagewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page); -extern void eepromN25Q128pageread(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page); -extern void eepromN25Q128bytewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char data); -extern unsigned char eepromN25Q128byteread(eepromN25Q128Dev* dev,uint32_t address); -extern void eepromN25Q128readn(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count); -extern void eepromN25Q128writen(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count); -extern void eepromN25Q128enablewrite(eepromN25Q128Dev* dev); - - - - -#endif - - - - - - - diff --git a/include/PERIPHERALS/adc.h b/include/PERIPHERALS/adc.h new file mode 100644 --- /dev/null +++ b/include/PERIPHERALS/adc.h @@ -0,0 +1,138 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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@gmail.com +-------------------------------------------------------------------------------*/ +/* +*/ + +#ifndef ADC_H +#define ADC_H +#include + +#ifdef __cplusplus + extern "C" { +#endif + + +typedef struct adc_t +{ + void* _dev; + int cfg; + int rate; +}adc_t; + + +typedef enum +{ + adc6bits = 0x1, + adc7bits = 0x2, + adc8bits = 0x3, + adc9bits = 0x4, + adc10bits = 0x5, + adc11bits = 0x6, + adc12bits = 0x7, + adc13bits = 0x8, + adc14bits = 0x9, + adc15bits = 0xA, + adc16bits = 0xB, + adc17bits = 0xC, + adc18bits = 0xD, + adc19bits = 0xE, + adc20bits = 0xF, + adc21bits = 0x10, + adc22bits = 0x11, + adc23bits = 0x12, + adc24bits = 0x13 +}adcbits_t; + +#define ADCBITSMASK 0xF + +typedef enum +{ + adcsingle = 0x00, + adcmaster = 0x10 +}adcconvmode_t; + +#define ADCCONVMODEMASK 0x10 + +typedef enum +{ + spiclkinhlow = 0x00, + spiclkinhhigh = 0x20 +}spiclkinhlvl_t; + +#define SPICLKINHLVLMASK 0x20 + + +typedef enum +{ + spiclkfirstedge = 0x00, + spiclksecondedge = 0x40 +}spiclkphase_t; + +#define SPICLKPHASEMASK 0x40 + +typedef enum +{ + spimsbfirst = 0x00, + spilsbfirst = 0x80 +}spibitorder_t; + +#define SPIBITORDERMASK 0x80 + + +extern int spiopen(int count,spi_t* spidev); +extern int spiopenandconfig(int count,spi_t* spidev,uint32_t cfg,uint32_t speed,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin); +extern int spiclose(spi_t* spidev); +extern int spisetpins(spi_t* spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin); +extern int spienable(spi_t* spidev); +extern int spidisable(spi_t* spidev); +extern int spisetconfig(spi_t* spidev); +extern int spisetspeed(spi_t* spidev, uint32_t speed); +extern int spisetbitorder(spi_t* spidev,spibitorder_t order); +extern int spisetdatabits(spi_t* spidev,spibits_t bitscnt); +extern int spisetclkinhlevel(spi_t* spidev,spiclkinhlvl_t level); +extern int spisetclkphase(spi_t* spidev,spiclkphase_t phase); +extern int spiputw(spi_t* spidev,uint16_t data); +extern uint16_t spigetw(spi_t* spidev); +extern int spiputs(spi_t* spidev,char* s); +extern int spigets(spi_t* spidev,char* s); +extern int spiputnw(spi_t* spidev,uint16_t* w,int n); +extern int spigetnw(spi_t* spidev,uint16_t* w,int n); +extern int spiputnc(spi_t* spidev,char* c,int n); +extern int spigetnc(spi_t* spidev,char* c,int n); +extern int spiavailiabledata(spi_t* spidev); + +#ifdef __cplusplus + } +#endif +#endif //ADC_H + + + + + + + + + + + + diff --git a/include/PERIPHERALS/gpio.h b/include/PERIPHERALS/gpio.h new file mode 100644 --- /dev/null +++ b/include/PERIPHERALS/gpio.h @@ -0,0 +1,590 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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@gmail.com +-------------------------------------------------------------------------------*/ + +/*! \file gpio.h +\brief GPIO api. + +The gpio api gives you a standard way to drive any gpio on any processor. +With this api you will be able to open and configure your gpios and set/clear read them. + +A simple example to drive PA0 and read PA1. + \code + // lets open PA0 and PA1 + gpio_t mygpio1 gpioopen(PA0); + gpioopen(PA1); + mygpio1 |= gpiohighspeed | gpiooutdir | gpiopushpulltype | gpionopulltype; + gpiosetconfig(mygpio1); + //you can also configure with the pin name + gpiosetconfig(PA1|gpiohighspeed | gpioindir); + //to set PA0 + gpioset(mygpio1); + //to clear it + gpioclr(PA0); //PA0 also works and save 4 bytes! + //Let read PA1 and write it to PA0 + gpiosetval(PA0,gpiogetval(PA1)); + \endcode + +*/ +#ifndef GPIO_H +#define GPIO_H +#include +#ifdef __cplusplus + extern "C" { +#endif + + +typedef uint32_t gpio_t; + +typedef enum gpiospeed_t +{ + gpiolowspeed = 0x00000, + gpiomediumspeed = 0x10000, + gpiofastspeed = 0x20000, + gpiohighspeed = 0x30000 +}gpiospeed_t; + + + +typedef enum gpiodir_t +{ + gpioindir = 0x00000, + gpiooutdir = 0x40000, + gpioaf = 0x80000, + gpioan = 0xC0000 +}gpiodir_t; + + + + +typedef enum gpioouttype_t +{ + gpiopushpulltype = 0x000000, + gpioopendraintype = 0x100000 +}gpioouttype_t; + + + +typedef enum gpiopulltype_t +{ + gpionopulltype = 0x000000, + gpiopulluptype = 0x200000, + gpiopulldowntype = 0x400000 +}gpiopulltype_t; + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + #define GPIOSPEEDMASK 0x30000 + #define GPIODIRMASK 0xC0000 + #define GPIOOUTTYPEMASK 0x100000 + #define GPIOPULLTYPEMASK 0x600000 +#endif + + +extern gpio_t gpioopen(uint32_t gpio); +extern void gpioclose(gpio_t gpio); +extern void gpiosetconfig(gpio_t* gpio); +extern void gpiosetdir(gpio_t* gpio,gpiodir_t dir); +extern void gpiosetouttype(gpio_t* gpio, gpioouttype_t outtype); +extern void gpiosetpulltype(gpio_t* gpio,gpiopulltype_t pulltype); +extern void gpiosetspeed(gpio_t* gpio,gpiospeed_t speed); +extern void gpioset(gpio_t gpio); +extern void gpioclr(gpio_t gpio); +extern void gpiosetval(gpio_t gpio,int val); +extern int gpiogetval(gpio_t gpio); + +#define GPIOISINPUT(gpio) (((gpio) & GPIODIRMASK)==gpioindir) +#define GPIOISOUTPUT(gpio) (((gpio) & GPIOSPEEDMASK)==gpiooutdir) + +#define GPIOISLOWSPEED(gpio) (((gpio) & GPIOSPEEDMASK)==gpiolowspeed) +#define GPIOISMEDIUMSPEED(gpio) (((gpio) & GPIOSPEEDMASK)==gpiomediumspeed) +#define GPIOISFASTPEED(gpio) (((gpio) & GPIOSPEEDMASK)==gpiofastspeed) +#define GPIOISHIGHSPEED(gpio) (((gpio) & GPIOSPEEDMASK)==gpiohighspeeds) + +#define GPIOISPUSHPULL(gpio) (((gpio) & GPIOOUTTYPEMASK)==gpiopushpulltype) +#define GPIOISOPENDRAIN(gpio) (((gpio) & GPIOOUTTYPEMASK)==gpioopendraintype) + +#define GPIOISNOPULL(GPIO) (((gpio) & GPIOPULLTYPEMASK)==gpionopulltype) +#define GPIOISPULLUP(GPIO) (((gpio) & GPIOPULLTYPEMASK)==gpiopulluptype) +#define GPIOISPULLDOWN(GPIO) (((gpio) & GPIOPULLTYPEMASK)==gpiopulldowntype) + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +#define PA0 ((0<<8)+0) +#define PA1 ((0<<8)+1) +#define PA2 ((0<<8)+2) +#define PA3 ((0<<8)+3) +#define PA4 ((0<<8)+4) +#define PA5 ((0<<8)+5) +#define PA6 ((0<<8)+6) +#define PA7 ((0<<8)+7) +#define PA8 ((0<<8)+8) +#define PA9 ((0<<8)+9) +#define PA10 ((0<<8)+10) +#define PA11 ((0<<8)+11) +#define PA12 ((0<<8)+12) +#define PA13 ((0<<8)+13) +#define PA14 ((0<<8)+14) +#define PA15 ((0<<8)+15) +#define PAX ((0<<8)+255) +#define PB0 ((1<<8)+0) +#define PB1 ((1<<8)+1) +#define PB2 ((1<<8)+2) +#define PB3 ((1<<8)+3) +#define PB4 ((1<<8)+4) +#define PB5 ((1<<8)+5) +#define PB6 ((1<<8)+6) +#define PB7 ((1<<8)+7) +#define PB8 ((1<<8)+8) +#define PB9 ((1<<8)+9) +#define PB10 ((1<<8)+10) +#define PB11 ((1<<8)+11) +#define PB12 ((1<<8)+12) +#define PB13 ((1<<8)+13) +#define PB14 ((1<<8)+14) +#define PB15 ((1<<8)+15) +#define PBX ((1<<8)+255) +#define PC0 ((2<<8)+0) +#define PC1 ((2<<8)+1) +#define PC2 ((2<<8)+2) +#define PC3 ((2<<8)+3) +#define PC4 ((2<<8)+4) +#define PC5 ((2<<8)+5) +#define PC6 ((2<<8)+6) +#define PC7 ((2<<8)+7) +#define PC8 ((2<<8)+8) +#define PC9 ((2<<8)+9) +#define PC10 ((2<<8)+10) +#define PC11 ((2<<8)+11) +#define PC12 ((2<<8)+12) +#define PC13 ((2<<8)+13) +#define PC14 ((2<<8)+14) +#define PC15 ((2<<8)+15) +#define PCX ((2<<8)+255) +#define PD0 ((3<<8)+0) +#define PD1 ((3<<8)+1) +#define PD2 ((3<<8)+2) +#define PD3 ((3<<8)+3) +#define PD4 ((3<<8)+4) +#define PD5 ((3<<8)+5) +#define PD6 ((3<<8)+6) +#define PD7 ((3<<8)+7) +#define PD8 ((3<<8)+8) +#define PD9 ((3<<8)+9) +#define PD10 ((3<<8)+10) +#define PD11 ((3<<8)+11) +#define PD12 ((3<<8)+12) +#define PD13 ((3<<8)+13) +#define PD14 ((3<<8)+14) +#define PD15 ((3<<8)+15) +#define PDX ((3<<8)+255) +#define PE0 ((4<<8)+0) +#define PE1 ((4<<8)+1) +#define PE2 ((4<<8)+2) +#define PE3 ((4<<8)+3) +#define PE4 ((4<<8)+4) +#define PE5 ((4<<8)+5) +#define PE6 ((4<<8)+6) +#define PE7 ((4<<8)+7) +#define PE8 ((4<<8)+8) +#define PE9 ((4<<8)+9) +#define PE10 ((4<<8)+10) +#define PE11 ((4<<8)+11) +#define PE12 ((4<<8)+12) +#define PE13 ((4<<8)+13) +#define PE14 ((4<<8)+14) +#define PE15 ((4<<8)+15) +#define PEX ((4<<8)+255) +#define PF0 ((5<<8)+0) +#define PF1 ((5<<8)+1) +#define PF2 ((5<<8)+2) +#define PF3 ((5<<8)+3) +#define PF4 ((5<<8)+4) +#define PF5 ((5<<8)+5) +#define PF6 ((5<<8)+6) +#define PF7 ((5<<8)+7) +#define PF8 ((5<<8)+8) +#define PF9 ((5<<8)+9) +#define PF10 ((5<<8)+10) +#define PF11 ((5<<8)+11) +#define PF12 ((5<<8)+12) +#define PF13 ((5<<8)+13) +#define PF14 ((5<<8)+14) +#define PF15 ((5<<8)+15) +#define PFX ((5<<8)+255) +#define PG0 ((6<<8)+0) +#define PG1 ((6<<8)+1) +#define PG2 ((6<<8)+2) +#define PG3 ((6<<8)+3) +#define PG4 ((6<<8)+4) +#define PG5 ((6<<8)+5) +#define PG6 ((6<<8)+6) +#define PG7 ((6<<8)+7) +#define PG8 ((6<<8)+8) +#define PG9 ((6<<8)+9) +#define PG10 ((6<<8)+10) +#define PG11 ((6<<8)+11) +#define PG12 ((6<<8)+12) +#define PG13 ((6<<8)+13) +#define PG14 ((6<<8)+14) +#define PG15 ((6<<8)+15) +#define PGX ((6<<8)+255) +#define PH0 ((7<<8)+0) +#define PH1 ((7<<8)+1) +#define PH2 ((7<<8)+2) +#define PH3 ((7<<8)+3) +#define PH4 ((7<<8)+4) +#define PH5 ((7<<8)+5) +#define PH6 ((7<<8)+6) +#define PH7 ((7<<8)+7) +#define PH8 ((7<<8)+8) +#define PH9 ((7<<8)+9) +#define PH10 ((7<<8)+10) +#define PH11 ((7<<8)+11) +#define PH12 ((7<<8)+12) +#define PH13 ((7<<8)+13) +#define PH14 ((7<<8)+14) +#define PH15 ((7<<8)+15) +#define PHX ((7<<8)+255) +#define PI0 ((8<<8)+0) +#define PI1 ((8<<8)+1) +#define PI2 ((8<<8)+2) +#define PI3 ((8<<8)+3) +#define PI4 ((8<<8)+4) +#define PI5 ((8<<8)+5) +#define PI6 ((8<<8)+6) +#define PI7 ((8<<8)+7) +#define PI8 ((8<<8)+8) +#define PI9 ((8<<8)+9) +#define PI10 ((8<<8)+10) +#define PI11 ((8<<8)+11) +#define PI12 ((8<<8)+12) +#define PI13 ((8<<8)+13) +#define PI14 ((8<<8)+14) +#define PI15 ((8<<8)+15) +#define PIX ((8<<8)+255) +#define PJ0 ((9<<8)+0) +#define PJ1 ((9<<8)+1) +#define PJ2 ((9<<8)+2) +#define PJ3 ((9<<8)+3) +#define PJ4 ((9<<8)+4) +#define PJ5 ((9<<8)+5) +#define PJ6 ((9<<8)+6) +#define PJ7 ((9<<8)+7) +#define PJ8 ((9<<8)+8) +#define PJ9 ((9<<8)+9) +#define PJ10 ((9<<8)+10) +#define PJ11 ((9<<8)+11) +#define PJ12 ((9<<8)+12) +#define PJ13 ((9<<8)+13) +#define PJ14 ((9<<8)+14) +#define PJ15 ((9<<8)+15) +#define PJX ((9<<8)+255) +#define PK0 ((10<<8)+0) +#define PK1 ((10<<8)+1) +#define PK2 ((10<<8)+2) +#define PK3 ((10<<8)+3) +#define PK4 ((10<<8)+4) +#define PK5 ((10<<8)+5) +#define PK6 ((10<<8)+6) +#define PK7 ((10<<8)+7) +#define PK8 ((10<<8)+8) +#define PK9 ((10<<8)+9) +#define PK10 ((10<<8)+10) +#define PK11 ((10<<8)+11) +#define PK12 ((10<<8)+12) +#define PK13 ((10<<8)+13) +#define PK14 ((10<<8)+14) +#define PK15 ((10<<8)+15) +#define PKX ((10<<8)+255) +#define PL0 ((11<<8)+0) +#define PL1 ((11<<8)+1) +#define PL2 ((11<<8)+2) +#define PL3 ((11<<8)+3) +#define PL4 ((11<<8)+4) +#define PL5 ((11<<8)+5) +#define PL6 ((11<<8)+6) +#define PL7 ((11<<8)+7) +#define PL8 ((11<<8)+8) +#define PL9 ((11<<8)+9) +#define PL10 ((11<<8)+10) +#define PL11 ((11<<8)+11) +#define PL12 ((11<<8)+12) +#define PL13 ((11<<8)+13) +#define PL14 ((11<<8)+14) +#define PL15 ((11<<8)+15) +#define PLX ((11<<8)+255) +#define PM0 ((12<<8)+0) +#define PM1 ((12<<8)+1) +#define PM2 ((12<<8)+2) +#define PM3 ((12<<8)+3) +#define PM4 ((12<<8)+4) +#define PM5 ((12<<8)+5) +#define PM6 ((12<<8)+6) +#define PM7 ((12<<8)+7) +#define PM8 ((12<<8)+8) +#define PM9 ((12<<8)+9) +#define PM10 ((12<<8)+10) +#define PM11 ((12<<8)+11) +#define PM12 ((12<<8)+12) +#define PM13 ((12<<8)+13) +#define PM14 ((12<<8)+14) +#define PM15 ((12<<8)+15) +#define PMX ((12<<8)+255) +#define PN0 ((13<<8)+0) +#define PN1 ((13<<8)+1) +#define PN2 ((13<<8)+2) +#define PN3 ((13<<8)+3) +#define PN4 ((13<<8)+4) +#define PN5 ((13<<8)+5) +#define PN6 ((13<<8)+6) +#define PN7 ((13<<8)+7) +#define PN8 ((13<<8)+8) +#define PN9 ((13<<8)+9) +#define PN10 ((13<<8)+10) +#define PN11 ((13<<8)+11) +#define PN12 ((13<<8)+12) +#define PN13 ((13<<8)+13) +#define PN14 ((13<<8)+14) +#define PN15 ((13<<8)+15) +#define PNX ((13<<8)+255) +#define PO0 ((14<<8)+0) +#define PO1 ((14<<8)+1) +#define PO2 ((14<<8)+2) +#define PO3 ((14<<8)+3) +#define PO4 ((14<<8)+4) +#define PO5 ((14<<8)+5) +#define PO6 ((14<<8)+6) +#define PO7 ((14<<8)+7) +#define PO8 ((14<<8)+8) +#define PO9 ((14<<8)+9) +#define PO10 ((14<<8)+10) +#define PO11 ((14<<8)+11) +#define PO12 ((14<<8)+12) +#define PO13 ((14<<8)+13) +#define PO14 ((14<<8)+14) +#define PO15 ((14<<8)+15) +#define POX ((14<<8)+255) +#define PP0 ((15<<8)+0) +#define PP1 ((15<<8)+1) +#define PP2 ((15<<8)+2) +#define PP3 ((15<<8)+3) +#define PP4 ((15<<8)+4) +#define PP5 ((15<<8)+5) +#define PP6 ((15<<8)+6) +#define PP7 ((15<<8)+7) +#define PP8 ((15<<8)+8) +#define PP9 ((15<<8)+9) +#define PP10 ((15<<8)+10) +#define PP11 ((15<<8)+11) +#define PP12 ((15<<8)+12) +#define PP13 ((15<<8)+13) +#define PP14 ((15<<8)+14) +#define PP15 ((15<<8)+15) +#define PPX ((15<<8)+255) +#define PQ0 ((16<<8)+0) +#define PQ1 ((16<<8)+1) +#define PQ2 ((16<<8)+2) +#define PQ3 ((16<<8)+3) +#define PQ4 ((16<<8)+4) +#define PQ5 ((16<<8)+5) +#define PQ6 ((16<<8)+6) +#define PQ7 ((16<<8)+7) +#define PQ8 ((16<<8)+8) +#define PQ9 ((16<<8)+9) +#define PQ10 ((16<<8)+10) +#define PQ11 ((16<<8)+11) +#define PQ12 ((16<<8)+12) +#define PQ13 ((16<<8)+13) +#define PQ14 ((16<<8)+14) +#define PQ15 ((16<<8)+15) +#define PQX ((16<<8)+255) +#define PR0 ((17<<8)+0) +#define PR1 ((17<<8)+1) +#define PR2 ((17<<8)+2) +#define PR3 ((17<<8)+3) +#define PR4 ((17<<8)+4) +#define PR5 ((17<<8)+5) +#define PR6 ((17<<8)+6) +#define PR7 ((17<<8)+7) +#define PR8 ((17<<8)+8) +#define PR9 ((17<<8)+9) +#define PR10 ((17<<8)+10) +#define PR11 ((17<<8)+11) +#define PR12 ((17<<8)+12) +#define PR13 ((17<<8)+13) +#define PR14 ((17<<8)+14) +#define PR15 ((17<<8)+15) +#define PRX ((17<<8)+255) +#define PS0 ((18<<8)+0) +#define PS1 ((18<<8)+1) +#define PS2 ((18<<8)+2) +#define PS3 ((18<<8)+3) +#define PS4 ((18<<8)+4) +#define PS5 ((18<<8)+5) +#define PS6 ((18<<8)+6) +#define PS7 ((18<<8)+7) +#define PS8 ((18<<8)+8) +#define PS9 ((18<<8)+9) +#define PS10 ((18<<8)+10) +#define PS11 ((18<<8)+11) +#define PS12 ((18<<8)+12) +#define PS13 ((18<<8)+13) +#define PS14 ((18<<8)+14) +#define PS15 ((18<<8)+15) +#define PSX ((18<<8)+255) +#define PT0 ((19<<8)+0) +#define PT1 ((19<<8)+1) +#define PT2 ((19<<8)+2) +#define PT3 ((19<<8)+3) +#define PT4 ((19<<8)+4) +#define PT5 ((19<<8)+5) +#define PT6 ((19<<8)+6) +#define PT7 ((19<<8)+7) +#define PT8 ((19<<8)+8) +#define PT9 ((19<<8)+9) +#define PT10 ((19<<8)+10) +#define PT11 ((19<<8)+11) +#define PT12 ((19<<8)+12) +#define PT13 ((19<<8)+13) +#define PT14 ((19<<8)+14) +#define PT15 ((19<<8)+15) +#define PTX ((19<<8)+255) +#define PU0 ((20<<8)+0) +#define PU1 ((20<<8)+1) +#define PU2 ((20<<8)+2) +#define PU3 ((20<<8)+3) +#define PU4 ((20<<8)+4) +#define PU5 ((20<<8)+5) +#define PU6 ((20<<8)+6) +#define PU7 ((20<<8)+7) +#define PU8 ((20<<8)+8) +#define PU9 ((20<<8)+9) +#define PU10 ((20<<8)+10) +#define PU11 ((20<<8)+11) +#define PU12 ((20<<8)+12) +#define PU13 ((20<<8)+13) +#define PU14 ((20<<8)+14) +#define PU15 ((20<<8)+15) +#define PUX ((20<<8)+255) +#define PV0 ((21<<8)+0) +#define PV1 ((21<<8)+1) +#define PV2 ((21<<8)+2) +#define PV3 ((21<<8)+3) +#define PV4 ((21<<8)+4) +#define PV5 ((21<<8)+5) +#define PV6 ((21<<8)+6) +#define PV7 ((21<<8)+7) +#define PV8 ((21<<8)+8) +#define PV9 ((21<<8)+9) +#define PV10 ((21<<8)+10) +#define PV11 ((21<<8)+11) +#define PV12 ((21<<8)+12) +#define PV13 ((21<<8)+13) +#define PV14 ((21<<8)+14) +#define PV15 ((21<<8)+15) +#define PVX ((21<<8)+255) +#define PW0 ((22<<8)+0) +#define PW1 ((22<<8)+1) +#define PW2 ((22<<8)+2) +#define PW3 ((22<<8)+3) +#define PW4 ((22<<8)+4) +#define PW5 ((22<<8)+5) +#define PW6 ((22<<8)+6) +#define PW7 ((22<<8)+7) +#define PW8 ((22<<8)+8) +#define PW9 ((22<<8)+9) +#define PW10 ((22<<8)+10) +#define PW11 ((22<<8)+11) +#define PW12 ((22<<8)+12) +#define PW13 ((22<<8)+13) +#define PW14 ((22<<8)+14) +#define PW15 ((22<<8)+15) +#define PWX ((22<<8)+255) +#define PX0 ((23<<8)+0) +#define PX1 ((23<<8)+1) +#define PX2 ((23<<8)+2) +#define PX3 ((23<<8)+3) +#define PX4 ((23<<8)+4) +#define PX5 ((23<<8)+5) +#define PX6 ((23<<8)+6) +#define PX7 ((23<<8)+7) +#define PX8 ((23<<8)+8) +#define PX9 ((23<<8)+9) +#define PX10 ((23<<8)+10) +#define PX11 ((23<<8)+11) +#define PX12 ((23<<8)+12) +#define PX13 ((23<<8)+13) +#define PX14 ((23<<8)+14) +#define PX15 ((23<<8)+15) +#define PXX ((23<<8)+255) +#define PY0 ((24<<8)+0) +#define PY1 ((24<<8)+1) +#define PY2 ((24<<8)+2) +#define PY3 ((24<<8)+3) +#define PY4 ((24<<8)+4) +#define PY5 ((24<<8)+5) +#define PY6 ((24<<8)+6) +#define PY7 ((24<<8)+7) +#define PY8 ((24<<8)+8) +#define PY9 ((24<<8)+9) +#define PY10 ((24<<8)+10) +#define PY11 ((24<<8)+11) +#define PY12 ((24<<8)+12) +#define PY13 ((24<<8)+13) +#define PY14 ((24<<8)+14) +#define PY15 ((24<<8)+15) +#define PYX ((24<<8)+255) +#define PZ0 ((25<<8)+0) +#define PZ1 ((25<<8)+1) +#define PZ2 ((25<<8)+2) +#define PZ3 ((25<<8)+3) +#define PZ4 ((25<<8)+4) +#define PZ5 ((25<<8)+5) +#define PZ6 ((25<<8)+6) +#define PZ7 ((25<<8)+7) +#define PZ8 ((25<<8)+8) +#define PZ9 ((25<<8)+9) +#define PZ10 ((25<<8)+10) +#define PZ11 ((25<<8)+11) +#define PZ12 ((25<<8)+12) +#define PZ13 ((25<<8)+13) +#define PZ14 ((25<<8)+14) +#define PZ15 ((25<<8)+15) +#define PZX ((25<<8)+255) + +#endif + +#ifdef __cplusplus + } +#endif +#endif //GPIO_H + + + + + + + + + + + + diff --git a/include/PERIPHERALS/i2c.h b/include/PERIPHERALS/i2c.h new file mode 100644 --- /dev/null +++ b/include/PERIPHERALS/i2c.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef I2C_H +#define I2C_H +#include + +#ifdef __cplusplus + extern "C" { +#endif + +typedef int i2c_t; + +#define i2c1 0 +#define i2c2 1 +#define i2c3 2 +#define i2c4 3 +#define i2c5 4 +#define i2c6 5 +#define i2c7 6 +#define i2c8 7 +#define i2c9 8 + +extern int i2ctimeout; + +extern i2c_t i2copen(int count); +extern i2c_t i2copenandconfig(int count ,uint32_t cfg,uint32_t speed,uint32_t SDA,uint32_t SCL); +extern int i2cclose(i2c_t dev); +extern int i2csetpins(i2c_t dev,uint32_t SDA,uint32_t SCL); +extern int i2cenable(i2c_t dev); +extern int i2cdisable(i2c_t dev); +//extern int i2csetconfig(i2c_t dev); +extern int i2csetspeed(i2c_t dev,uint32_t speed); +//extern int i2csetdatabits(i2c_t* dev,uartbits_t databits); +extern int i2cwrite(i2c_t dev,char address,char* data,int count); +extern int i2cread(i2c_t dev,char address,char* data,int count); +extern int i2cbusy(i2c_t dev); +extern int i2cStatusCheck(i2c_t dev,int32_t flagMask); +#ifdef __cplusplus + } +#endif +#endif //I2C_H + + + + + + + + + + + + diff --git a/include/PERIPHERALS/spi.h b/include/PERIPHERALS/spi.h new file mode 100644 --- /dev/null +++ b/include/PERIPHERALS/spi.h @@ -0,0 +1,150 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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 +-------------------------------------------------------------------------------*/ +/* + TODO: + Add SPI slave mode + Add interrupt interface +*/ + +#ifndef SPI_H +#define SPI_H +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/* +typedef struct spi_t +{ + void* _dev; + int cfg; + int speed; +}spi_t;*/ + +typedef int spi_t; + + #define spi1 ((spi_t)0) + #define spi2 ((spi_t)1) + #define spi3 ((spi_t)2) + #define spi4 ((spi_t)3) + #define spi5 ((spi_t)4) + #define spi6 ((spi_t)5) + #define spi7 ((spi_t)6) + #define spi8 ((spi_t)7) + #define spi9 ((spi_t)8) + + +typedef enum +{ + spi4bits = 0x3, + spi5bits = 0x4, + spi6bits = 0x5, + spi7bits = 0x6, + spi8bits = 0x7, + spi9bits = 0x8, + spi10bits = 0x9, + spi11bits = 0xA, + spi12bits = 0xB, + spi13bits = 0xC, + spi14bits = 0xD, + spi15bits = 0xE, + spi16bits = 0xF +}spibits_t; + +#define SPIBITSMASK 0xF + +typedef enum +{ + spislave = 0x00, + spimaster = 0x10 +}spimode_t; + +#define SPIMODEMASK 0x10 + +typedef enum +{ + spiclkinhlow = 0x00, + spiclkinhhigh = 0x20 +}spiclkinhlvl_t; + +#define SPICLKINHLVLMASK 0x20 + + +typedef enum +{ + spiclkfirstedge = 0x00, + spiclksecondedge = 0x40 +}spiclkphase_t; + +#define SPICLKPHASEMASK 0x40 + +typedef enum +{ + spimsbfirst = 0x00, + spilsbfirst = 0x80 +}spibitorder_t; + +#define SPIBITORDERMASK 0x80 + + +extern spi_t spiopen(int count); +extern spi_t spiopenandconfig(int count,uint32_t cfg,uint32_t speed,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin); +extern int spiclose(spi_t spidev); +extern int spisetpins(spi_t spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin); +extern int spienable(spi_t spidev); +extern int spidisable(spi_t spidev); +extern int spitransactionfinished(spi_t spidev); +extern int spisetconfig(spi_t spidev,uint32_t config,uint32_t speed); +extern int spisetspeed(spi_t spidev, uint32_t speed); +extern uint32_t spigetspeed(spi_t spidev); +extern int spisetbitorder(spi_t spidev,spibitorder_t order); +extern int spisetdatabits(spi_t spidev,spibits_t bitscnt); +extern int spisetclkinhlevel(spi_t spidev,spiclkinhlvl_t level); +extern int spisetclkphase(spi_t spidev,spiclkphase_t phase); +extern int spiputw(spi_t spidev,uint16_t data); +extern uint16_t spigetw(spi_t spidev); +extern uint16_t spigetw2(spi_t spidev,uint16_t data); +extern int spiputs(spi_t spidev,char* s); +extern int spigets(spi_t spidev,char* s); +extern int spiputnw(spi_t spidev,uint16_t* w,int n); +extern int spigetnw(spi_t spidev,uint16_t* w,int n); +extern int spiputnc(spi_t spidev,char* c,int n); +extern int spigetnc(spi_t spidev,char* c,int n); +extern int spiavailiabledata(spi_t spidev); + +#ifdef __cplusplus + } +#endif +#endif //SPI_H + + + + + + + + + + + + diff --git a/include/PERIPHERALS/uart.h b/include/PERIPHERALS/uart.h new file mode 100644 --- /dev/null +++ b/include/PERIPHERALS/uart.h @@ -0,0 +1,319 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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@gmail.com +-------------------------------------------------------------------------------*/ +/*! \file uart.h +\brief UART api. + +The uart api gives you a standard way to drive any uart on any processor. +With this api you will be able to open and configure your UART define the +associated pins when applicable and read/write on it. Note that depending +on the target architecture you can have soft or hard UART. + +A simple example to read or writes on uart1. + \code + // lets open uart1 + //config : + // -parity = No + // -data bits = 8 + // -stop bits = 1 + // -speed = 115200 bauds + // -TX = PA9 + // -RX = PA10 + // -CTS = unused (-1) + // -RTS = unused (-1) + uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); + //check that everything is ok + if(uart==uart1) + { + //to write 0xFF on uart1 + uartputc(uart,0xFF); + //you can also send a string on uart1 + char* buffer="hello"; + uartputs(uart,buffer); + //to read a char + char result = uartgetc(uart); + } + + \endcode + +*/ + +#ifndef UART_H +#define UART_H +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* +typedef volatile struct uart_t +{ + volatile void* _dev; + volatile int cfg; + volatile int speed; +}uart_t; + */ + +/** + * @brief uart handle + * + * uart_t is the handle type you will use for all uart related functions. + */ +typedef int uart_t; + +#define uart1 0 ///< uart1 +#define uart2 1 ///< uart2 +#define uart3 2 ///< uart3 +#define uart4 3 ///< uart4 +#define uart5 4 ///< uart5 +#define uart6 5 ///< uart6 +#define uart7 6 ///< uart7 +#define uart8 7 ///< uart8 +#define uart9 8 ///< uart9 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + #define UARTPARITYMASK 0x3 + #define UARTBITSMASK 0xC + #define UARTSTOPBITSMASK 0x70 +#endif + +/** + * @brief Uart parity enum + * + * Use uartparity_t values to configure the parity of your UART port with + * uartsetparity function or uartsetconfig. Don't try to use numerical values + * directly! + */ +typedef enum uartparity_t +{ + uartparitynone = 0x1, /**< No parity */ + uartparityeven = 0x2, /**< Even parity */ + uartparityodd = 0x3 /**< Odd parity */ +}uartparity_t; + +/** + * @brief Uart data bits enum + * + * Use uartbits_t values to configure the number of data bits of your UART port with + * uartsetdatabits function or uartsetconfig. Don't try to use numerical values + * directly! + */ +typedef enum uartbits_t +{ + uart7bits = 0x4, /**< 7 data bits communication */ + uart8bits = 0x8, /**< 8 data bits communication */ + uart9bits = 0xC /**< 9 data bits communication */ +}uartbits_t; + +/** + * @brief Uart stop bits enum + * + * Use uartstopbits_t values to configure the number of stop bits of your UART port with + * uartsetstopbits function or uartsetconfig. Don't try to use numerical values + * directly! + */ +typedef enum uartstopbits_t +{ + uarthalfstop = 0x10, /**< 0.5 stop bits communication */ + uartonestop = 0x20, /**< 1 stop bits communication */ + uartonehalfstop = 0x30, /**< 1.5 stop bits communication */ + uarttwostop = 0x40 /**< 2 stop bits communication */ +}uartstopbits_t; + + + +/** + * @brief Uart open function + * + * This function opens the given uart, it should turn it ON iff needed and enable it. + * @param count The uart identifier uart1 for example + * @return The uart identifier on success or -1 if it fails. + */ +extern uart_t uartopen(int count); +/** + * @brief Uart open and configure function + * + * This function call uartopen and configure the UART with the given parameters. + * @param count The uart identifier uart1 for example + * @param cfg The configuration of the UART, build from an or mask. + * @param speed The target speed of the UART in bauds, the real speed depend on the implementation + * and the target. + * @param TXpin The TXpin look gpio api. + * @param RXpin The RXpin look gpio api. + * @param RTSpin The RTSpin look gpio api. + * @param CTSpin The CTSpin look gpio api. + * @return The uart identifier on success or -1 if it fails. + * @sa uartclose(uart_t uart), uartopenandconfig(int count ,uint32_t cfg,uint32_t speed,uint32_t TXpin,uint32_t RXpin,uint32_t RTSpin,uint32_t CTSpin), uartsetconfig(uart_t uart,uint32_t cfg,uint32_t speed) + */ +extern uart_t uartopenandconfig(int count ,uint32_t cfg,uint32_t speed,uint32_t TXpin,uint32_t RXpin,uint32_t RTSpin,uint32_t CTSpin); +/** + * @brief Uart close function + * + * This function should at least reset the UART configuration. + * @param uart The uart identifier uart1 for example. + * @return 1 on success or -1 on error. + */ +extern int uartclose(uart_t uart); +/** + * @brief uart set pins function + * + * This function sets the Uart pins, you have to check for each target that the pins you selected + * are compatible with the desired function. + * @param uart The uart identifier uart1 for example. + * @param TXpin The TXpin look gpio api. + * @param RXpin The RXpin look gpio api. + * @param RTSpin The RTSpin look gpio api. + * @param CTSpin The CTSpin look gpio api. + * @return 1 on success or -1 on error. + * @sa uartopen(int count) + */ +extern int uartsetpins(uart_t uart,uint32_t TXpin,uint32_t RXpin,uint32_t RTSpin,uint32_t CTSpin); +/** + * @brief Enable uart functionnable + * + *This function enables given uart, it makes sens on target where you can enable or disable + *the uart. + * @param uart The uart identifier uart1 for example. + * @return 1 on success or -1 on error. + * @sa uartenable(uart_t uart) + */ +extern int uartenable(uart_t uart); +/** + * @brief Disable uart function + * + *This function disables given uart, it makes sens on target where you can enable or disable + *the uart. + * @param uart The uart identifier uart1 for example. + * @return 1 on success or -1 on error. + */ +extern int uartdisable(uart_t uart); +/** + * @brief uart set configuration function + * + * This function configure the given uart. + * @param uart The uart identifier uart1 for example. + * @param cfg + * @param speed + * @return + */ +extern int uartsetconfig(uart_t uart,uint32_t cfg,uint32_t speed); +/** + * @brief uartsetspeed + * @param uart The uart identifier uart1 for example. + * @param speed + * @return + */ +extern int uartsetspeed(uart_t uart,uint32_t speed); +/** + * @brief uartsetparity + * @param uart The uart identifier uart1 for example. + * @param parity + * @return + */ +extern int uartsetparity(uart_t uart,uartparity_t parity); +/** + * @brief uartsetdatabits + * @param uart The uart identifier uart1 for example. + * @param databits + * @return + */ +extern int uartsetdatabits(uart_t uart,uartbits_t databits); +/** + * @brief uartsetstopbits + * @param uart The uart identifier uart1 for example. + * @param stopbits + * @return + */ +extern int uartsetstopbits(uart_t uart,uartstopbits_t stopbits); +/** + * @brief uartputc + * @param uart The uart identifier uart1 for example. + * @param c + * @return + */ +extern int uartputc(uart_t uart,char c); +/** + * @brief uartgetc + * @param uart The uart identifier uart1 for example. + * @return + */ +extern char uartgetc(uart_t uart); +/** + * @brief uartputs + * @param uart The uart identifier uart1 for example. + * @param s + * @return + */ +extern int uartputs(uart_t uart,char* s); +/** + * @brief uartgets + * @param uart The uart identifier uart1 for example. + * @param s + * @return + */ +extern int uartgets(uart_t uart,char* s); +/** + * @brief uartputnc + * @param uart The uart identifier uart1 for example. + * @param c + * @param n + * @return + */ +extern int uartputnc(uart_t uart,char* c,int n); +/** + * @brief uartgetnc + * @param uart The uart identifier uart1 for example. + * @param c + * @param n + * @return + */ +extern int uartgetnc(uart_t uart,char* c,int n); +/** + * @brief uartavailiabledata + * @param uart The uart identifier uart1 for example. + * @return + */ +extern int uartavailiabledata(uart_t uart); +/** + * @brief uartmkstreamdev + * @param uart The uart identifier uart1 for example. + * @param strdev + * @return + */ +extern int uartmkstreamdev(uart_t uart,streamdevice* strdev); + +#ifdef __cplusplus +} +#endif +#endif //SPI_H + + + + + + + + + + + + diff --git a/include/POWER/ina226.h b/include/POWER/ina226.h new file mode 100644 --- /dev/null +++ b/include/POWER/ina226.h @@ -0,0 +1,104 @@ +/*------------------------------------------------------------------------------ +-- 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@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef INA226_H +#define INA226_H + +#include +//#include + +typedef struct INA226_t +{ + i2c_t i2cdev; + uint8_t devAddress; + uint32_t shuntmOhm; + uint32_t CurrentRangeuAmp; +}INA226_t; + +extern int ina226open(INA226_t* dev,i2c_t i2cdev,uint16_t config,uint8_t A0,uint8_t A1,uint32_t shuntmOhm, uint32_t CurrentRangeuAmp); +extern uint16_t ina226getID(INA226_t* dev); +extern int ina226calibrate(INA226_t* dev,uint32_t shuntmOhm, uint32_t CurrentRangeuAmp); +extern uint32_t ina226getBusVoltage(INA226_t* dev); +extern uint32_t ina226getPower(INA226_t* dev); +extern int32_t ina226getCurrent(INA226_t* dev); +extern uint16_t ina226getReg(INA226_t* dev,char reg); +extern int ina226setReg(INA226_t* dev,char reg,int16_t value); + + +#define INA226_I2C_ADDRESS 0x40 + + +#define INA226_Die_ID_Reg 0xFF +#define INA226_Configuration_Reg 0 +#define INA226_Shunt_Voltage_Reg 1 +#define INA226_Bus_Voltage_Reg 2 +#define INA226_Power_Reg 3 +#define INA226_Current_Reg 4 +#define INA226_Calibration_Reg 5 +#define INA226_Mask_Enable_Reg 6 +#define INA226_Alert_Limit_Reg 7 + +#define INA226_AVERAGES_1 0 +#define INA226_AVERAGES_4 (1<<9) +#define INA226_AVERAGES_16 (2<<9) +#define INA226_AVERAGES_64 (3<<9) +#define INA226_AVERAGES_128 (4<<9) +#define INA226_AVERAGES_256 (5<<9) +#define INA226_AVERAGES_512 (6<<9) +#define INA226_AVERAGES_1024 (7<<9) + +#define INA226_BUS_CONV_140us 0 +#define INA226_BUS_CONV_204us (1<<6) +#define INA226_BUS_CONV_332us (2<<6) +#define INA226_BUS_CONV_588us (3<<6) +#define INA226_BUS_CONV_1100us (4<<6) +#define INA226_BUS_CONV_2116us (5<<6) +#define INA226_BUS_CONV_4156us (6<<6) +#define INA226_BUS_CONV_8244us (7<<6) + +#define INA226_SHUNT_CONV_140us 0 +#define INA226_SHUNT_CONV_204us (1<<3) +#define INA226_SHUNT_CONV_332us (2<<3) +#define INA226_SHUNT_CONV_588us (3<<3) +#define INA226_SHUNT_CONV_1100us (4<<3) +#define INA226_SHUNT_CONV_2116us (5<<3) +#define INA226_SHUNT_CONV_4156us (6<<3) +#define INA226_SHUNT_CONV_8244us (7<<3) + +#define INA226_MODE_POWER_DOWN 0 +#define INA226_MODE_SHUNT_VOLTAGE_TRIGGERRED 1 +#define INA226_MODE_BUS_VOLTAGE_TRIGGERRED 2 +#define INA226_MODE_SHUNT_AND_BUS_TRIGGERRED 3 +#define INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS 5 +#define INA226_MODE_BUS_VOLTAGE_CONTINUOUS 6 +#define INA226_MODE_SHUNT_AND_BUS_CONTINUOUS 7 + + + + +#endif + + + + + + + diff --git a/include/VS10XX.h b/include/VS10XX.h deleted file mode 100644 --- a/include/VS10XX.h +++ /dev/null @@ -1,97 +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 VS10XX_H -#define VS10XX_H -#include -#include - -#define VSMODE 0 -#define VSSTATUS 1 -#define VSBASS 2 -#define VSCLOCKF 3 -#define VSDECODE_TIME 4 -#define VSAUDATA 5 -#define VSWRAM 6 -#define VSWRAMADDR 7 -#define VSHDAT0 8 -#define VSHDAT1 9 -#define VSAIADDR 0xA -#define VSVOL 0xB -#define VSAICTRL0 0xC -#define VSAICTRL1 0xD -#define VSAICTRL2 0xE -#define VSAICTRL3 0xF - -typedef enum VS10XXVER_en -{ - UNKNOWN, - VS1001, - VS1011, - VS1002, - VS1003, - VS1053, - VS1033, - VS1103 -}VS10XXVER_en; - -typedef struct vs10XXDev -{ - spi_t SPIdev; - void (*setxCS)(char); - void (*setxRST)(char); - void (*setxDCS)(char); - int (*getDREQ)(); - VS10XXVER_en VERSION; -}vs10XXDev; - - -void vs10XXopen(vs10XXDev* codec,spi_t dev, void (*setxCS)(char),void (*setxRST)(char),void (*setxDCS)(char),int (*getDREQ)()); -void vs10XXsoftreset(vs10XXDev* dev); -int vs10XXcmdread(vs10XXDev* dev,char address); -void vs10XXcmdwrite(vs10XXDev* dev,char address,int value); -void vs10XXstream32bytes(vs10XXDev* dev,char* buffer); -void vs10XXsetCansel(vs10XXDev* dev); -int vs10XXcanselAccepted(vs10XXDev* dev); -void vs10XXsoftReset(vs10XXDev* dev); -//extern void vs10XXclearXCS(); -//extern void vs10XXsetXCS(); -//extern int vs10XXDREQ(); - -#endif //VS10XX_H - - - - - - - - - - - - - - - - - - diff --git a/include/adc.h b/include/adc.h deleted file mode 100644 --- a/include/adc.h +++ /dev/null @@ -1,139 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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@gmail.com --------------------------------------------------------------------------------*/ -/* -*/ - -#ifndef ADC_H -#define ADC_H -#include -#include - -#ifdef __cplusplus - extern "C" { -#endif - - -typedef struct adc_t -{ - void* _dev; - int cfg; - int rate; -}adc_t; - - -typedef enum -{ - adc6bits = 0x1, - adc7bits = 0x2, - adc8bits = 0x3, - adc9bits = 0x4, - adc10bits = 0x5, - adc11bits = 0x6, - adc12bits = 0x7, - adc13bits = 0x8, - adc14bits = 0x9, - adc15bits = 0xA, - adc16bits = 0xB, - adc17bits = 0xC, - adc18bits = 0xD, - adc19bits = 0xE, - adc20bits = 0xF, - adc21bits = 0x10, - adc22bits = 0x11, - adc23bits = 0x12, - adc24bits = 0x13 -}adcbits_t; - -#define ADCBITSMASK 0xF - -typedef enum -{ - adcsingle = 0x00, - adcmaster = 0x10 -}adcconvmode_t; - -#define ADCCONVMODEMASK 0x10 - -typedef enum -{ - spiclkinhlow = 0x00, - spiclkinhhigh = 0x20 -}spiclkinhlvl_t; - -#define SPICLKINHLVLMASK 0x20 - - -typedef enum -{ - spiclkfirstedge = 0x00, - spiclksecondedge = 0x40 -}spiclkphase_t; - -#define SPICLKPHASEMASK 0x40 - -typedef enum -{ - spimsbfirst = 0x00, - spilsbfirst = 0x80 -}spibitorder_t; - -#define SPIBITORDERMASK 0x80 - - -extern int spiopen(int count,spi_t* spidev); -extern int spiopenandconfig(int count,spi_t* spidev,uint32_t cfg,uint32_t speed,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin); -extern int spiclose(spi_t* spidev); -extern int spisetpins(spi_t* spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin); -extern int spienable(spi_t* spidev); -extern int spidisable(spi_t* spidev); -extern int spisetconfig(spi_t* spidev); -extern int spisetspeed(spi_t* spidev, uint32_t speed); -extern int spisetbitorder(spi_t* spidev,spibitorder_t order); -extern int spisetdatabits(spi_t* spidev,spibits_t bitscnt); -extern int spisetclkinhlevel(spi_t* spidev,spiclkinhlvl_t level); -extern int spisetclkphase(spi_t* spidev,spiclkphase_t phase); -extern int spiputw(spi_t* spidev,uint16_t data); -extern uint16_t spigetw(spi_t* spidev); -extern int spiputs(spi_t* spidev,char* s); -extern int spigets(spi_t* spidev,char* s); -extern int spiputnw(spi_t* spidev,uint16_t* w,int n); -extern int spigetnw(spi_t* spidev,uint16_t* w,int n); -extern int spiputnc(spi_t* spidev,char* c,int n); -extern int spigetnc(spi_t* spidev,char* c,int n); -extern int spiavailiabledata(spi_t* spidev); - -#ifdef __cplusplus - } -#endif -#endif //ADC_H - - - - - - - - - - - - diff --git a/include/ads1278.h b/include/ads1278.h deleted file mode 100644 --- a/include/ads1278.h +++ /dev/null @@ -1,72 +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@gmail.com -#-------------------------------------------------------------------------------*/ -#ifndef ADS1278_H -#define ADS1278_H -#include - -typedef void (*set_clkdiv_t)(int val); -typedef void (*set_sync_t)(int val); -typedef void (*set_mode0_t)(int val); -typedef void (*set_mode1_t)(int val); -typedef void (*set_fsync_t)(int val); -typedef int (*ready_t)(); - -struct ads1278Regs -{ - sspDev SSP_device; - set_clkdiv_t set_clkdiv; - set_sync_t set_sync; - set_mode0_t set_mode0; - set_mode1_t set_mode1; - set_fsync_t set_fsync; - ready_t ready; -}; - -typedef struct ads1278Regs ads1278Dev; - -void ads1278open(ads1278Dev* codec,sspDev dev); -void ads1278sample(ads1278Dev* dev); -void ads1278readresult(ads1278Dev* dev,unsigned int* CH1,unsigned int* CH2,unsigned int* CH3,unsigned int* CH4,unsigned int* CH5,unsigned int* CH6,unsigned int* CH7,unsigned int* CH8); - -extern void bsp_ads1278_Sample(); -extern int bsp_ads1278_Ready(); -extern void bsp_ads1278_Synch(); - -#endif - - - - - - - - - - - - - - - - - - diff --git a/include/blkdevice.h b/include/blkdevice.h deleted file mode 100644 --- a/include/blkdevice.h +++ /dev/null @@ -1,128 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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@gmail.com --------------------------------------------------------------------------------*/ -#ifndef BLKDEVICE_H -#define BLKDEVICE_H -#include -/* Disk Status Bits (DSTATUS) */ - -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ -/* Generic ioctl command (defined for FatFs) */ -#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */ -#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */ -#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */ - -/* Generic ioctl command */ -#define CTRL_POWER 5 /* Get/Set power status */ -#define CTRL_LOCK 6 /* Lock/Unlock media removal */ -#define CTRL_EJECT 7 /* Eject media */ - -/* MMC/SDC specific ioctl command */ -#define MMC_GET_TYPE 10 /* Get card type */ -#define MMC_GET_CSD 11 /* Get CSD */ -#define MMC_GET_CID 12 /* Get CID */ -#define MMC_GET_OCR 13 /* Get OCR */ -#define MMC_GET_SDSTAT 14 /* Get SD status */ - -/* ATA/CF specific ioctl command */ -#define ATA_GET_REV 20 /* Get F/W revision */ -#define ATA_GET_MODEL 21 /* Get model name */ -#define ATA_GET_SN 22 /* Get serial number */ - -/* NAND specific ioctl command */ -#define NAND_FORMAT 30 /* Create physical format */ - -/* Status of Disk Functions */ -typedef unsigned char DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - -typedef volatile struct blkdevice* blkdeviceptr; - -typedef void (*blkdevselect_t)(char) ; -typedef void (*blkdevpower_t)(char) ; -typedef char (*blkdevdetect_t)() ; -typedef char (*blkdevwriteprotected_t)() ; -typedef DRESULT (*blkdevwrite_t)(blkdeviceptr _this,const char *buff,unsigned long sector,char count) ; -typedef DRESULT (*blkdevread_t)(blkdeviceptr _this,char *buff,unsigned long sector,char count) ; -typedef DRESULT (*blkdevioctl_t)(blkdeviceptr _this,char ctrl,void *buff) ; -typedef DSTATUS (*blkdevinitialize_t)(blkdeviceptr _this) ; -typedef DSTATUS (*blkdevstatus_t) (blkdeviceptr _this) ; - -typedef struct blkdevice -{ - UHANDLE phy; - unsigned int size; - unsigned int MaxSpeed; - unsigned char Version; - blkdevselect_t select; - blkdevpower_t power; - blkdevdetect_t detect; - blkdevwriteprotected_t writeprotected; - blkdevwrite_t write; - blkdevread_t read; - blkdevioctl_t ioctl; - blkdevinitialize_t initialize; - blkdevstatus_t status; -}blkdevice; - - - - - - -#endif - - - - - - - - - - - - - - - - - - - - - - diff --git a/include/fat32.h b/include/fat32.h deleted file mode 100644 --- a/include/fat32.h +++ /dev/null @@ -1,195 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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 FAT32_H -#define FAT32_H -#include -#include -#include -#include -#include -/*BPB (Boot Sector) Offsets */ - -#define BS_jmpBootoff 0 -#define BS_OEMNameoff 3 -#define BPB_BytsPerSecoff 11 -#define BPB_SecPerClusoff 13 -#define BPB_RsvdSecCntoff 14 -#define BPB_NumFATsoff 16 -#define BPB_RootEntCntoff 17 -#define BPB_TotSec16off 19 -#define BPB_Mediaoff 21 -#define BPB_FATSz16off 22 -#define BPB_SecPerTrkoff 24 -#define BPB_NumHeadsoff 26 -#define BPB_HiddSecoff 28 -#define BPB_TotSec32off 32 -/*FAT16*/ -#define BS_DrvNumFAT16off 36 -#define BS_Reserved1FAT16off 37 -#define BS_BootSigFAT16off 38 -#define BS_VolIDFAT16off 39 -#define BS_VolLabFAT16off 43 -#define BS_FilSysTypeFAT16off 54 -/*FAT32*/ -#define BPB_FATSz32off 36 -#define BPB_ExtFlagsoff 40 -#define BPB_FSVeroff 42 -#define BPB_RootClusoff 44 -#define BPB_FSInfooff 48 -#define BPB_BkBootSecoff 50 -#define BPB_Reservedoff 52 -#define BS_DrvNumFAT32off 64 -#define BS_Reserved1FAT32off 65 -#define BS_BootSigFAT32off 66 -#define BS_VolIDFAT32off 67 -#define BS_VolLabFAT32off 71 -#define BS_FilSysTypeFAT32off 82 - - -#define DIR_Nameoff 0 -#define DIR_Attroff 0xb -#define DIR_FstClusHIoff 0x14 -#define DIR_FstClusLOoff 0x1A -#define DIR_FileSizeoff 0x1c -#define DIR_CrtTimeTenthoff 13 -#define DIR_CrtTimeoff 14 -#define DIR_CrtDateoff 16 -#define DIR_LstAccDateoff 18 -#define DIR_WrtTimeoff 22 -#define DIR_WrtDateoff 24 - - - -#define FATBadpart 1 -#define FATBabArg 2 -#define FATReadErr 3 -#define FATnoErr 0 - -/* - TODO : - intergrate a per BLKDEV or per partition buffer. -*/ -typedef struct FAT32fs -{ - uint16_t BPB_BytsPerSec; - uint16_t BPB_RsvdSecCnt; - uint32_t BPB_FATSz32; - uint32_t BPB_RootClus; - uint32_t fat_begin_lba; - uint32_t cluster_begin_lba; - uint8_t BPB_SecPerClus; - uint8_t BPB_NumFATs; - char valide; - dikpartition* part; -}FAT32fs; - - -#define castUI64(val) ((uint64_t)(val)) -#define castUI32(val) ((uint32_t)(val)) -#define castUI16(val) ((uint16_t)(val)) -#define castUI8(val) ((uint8_t)(val)) - -#define castI64(val) ((int64_t)(val)) -#define castI32(val) ((int32_t)(val)) -#define castI16(val) ((int16_t)(val)) -#define castI8(val) ((int8_t)(val)) - -/* - TODO : - Should add global function for casting with endianness care. - have a look at REV, REV16, REVSH, and RBIT ARMV7m asm -*/ - -#if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ - #define fat32Ui8_2_Ui32(table,lsBindex) ((uint32_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint32_t)table[lsBindex+1])<<8))+(0xFF0000&(((uint32_t)table[lsBindex+2])<<16))+(0xFF000000&(((uint32_t)table[lsBindex+3])<<24)))) - #define fat32Ui8_2_Ui16(table,lsBindex) ((uint16_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint16_t)table[lsBindex+1])<<8)))) - #define fat32extract16b(table, LSBOffset) (uint16_t)(( (uint16_t) ((uint8_t)table[(LSBOffset)]) ) + (uint16_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )) - #define fat32extract32b(table, LSBOffset) (uint32_t)(( (uint32_t) ((uint8_t)table[(LSBOffset)]) ) + (uint32_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+2]) << 16 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+3]) << 24 )) -#else - #define fat32Ui8_2_Ui32(table,lsBindex) ((uint32_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint32_t)table[lsBindex+1])<<8))+(0xFF0000&(((uint32_t)table[lsBindex+2])<<16))+(0xFF000000&(((uint32_t)table[lsBindex+3])<<24)))) - #define fat32Ui8_2_Ui16(table,lsBindex) ((uint16_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint16_t)table[lsBindex+1])<<8)))) - #define fat32extract16b(table, LSBOffset) (uint16_t)(( (uint16_t) ((uint8_t)table[(LSBOffset)]) ) + (uint16_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )) - #define fat32extract32b(table, LSBOffset) (uint32_t)(( (uint32_t) ((uint8_t)table[(LSBOffset)]) ) + (uint32_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+2]) << 16 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+3]) << 24 )) -#endif - - -/* Get the first sector lba of given cluster number*/ -#define clusterlba(fs,cluster_number) ((uint32_t)fs->cluster_begin_lba + (((uint32_t)cluster_number) - (2)) * (uint32_t)fs->BPB_SecPerClus) - -//#define fat32clusterinfatsect(fs,cluster_number) ((((uint32_t)(cluster_number))>>6) + fs->fat_begin_lba) -#define fat32clusterinfatsect(fs,cluster_number) ((((uint32_t)(cluster_number))>>7) + fs->fat_begin_lba) -#define fat32clusterinfatoff(cluster_number) (((cluster_number)&0x7F)*4) - -/*Get cluster index in FAT Table from sector address*/ -#define fat32masksectorlba(sectorlba,fs) (sectorlba)//(sectorlba & (castUI32(-1)^castUI32(fs->BPB_SecPerClus-1))) -#define fat32sectorlbatoclusternum(fs,sectorlba) (((fat32masksectorlba(castUI32(sectorlba),fs) -(castUI32(fs->cluster_begin_lba)))/castUI32(fs->BPB_SecPerClus))+castUI32(2)) - - -#ifdef FAT32_PRIVATE -#define fat32sectorreadout(fs,fatsec) \ - if((lastSecAddrs!=(fatsec)) || (lastFATFS!=(fs))) /*Check if sector already buffered*/ \ - {\ - if((fs)->part->phy->read((fs)->part->phy,fat32buff,(fatsec),1)!=RES_OK) \ - {\ - return DIRENT_ReadErr;\ - }\ - }\ - lastSecAddrs=(fatsec);\ - lastFATFS=(fs); -#endif - -extern int fat32open(FAT32fs* fs,dikpartition* part); -extern int fat32mkdirent(FAT32fs* fs,ucdirent* dirent); -extern int fat32getVolName(FAT32fs* fs,char* Name); -extern int fat32getrootfirstent(ucdirent* entry); -extern int fat32nextdirent(ucdirent* entry); -extern int fat32nextsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t* nextsector_lba); -extern int fat32prevsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t *nextsector_lba); -extern int fat32prevsectorlba2(FAT32fs* fs,ucdirent* entry,uint32_t lastsector_lba,uint32_t *nextsector_lba); -extern uint32_t fat32getdirentlba(ucdirent* entry); -extern int fat32getdirentname(ucdirent* entry,char* nameBuffer); - -#endif - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/include/gpio.h b/include/gpio.h deleted file mode 100644 --- a/include/gpio.h +++ /dev/null @@ -1,557 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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@gmail.com --------------------------------------------------------------------------------*/ -#ifndef GPIO_H -#define GPIO_H -#include -#ifdef __cplusplus - extern "C" { -#endif - - -typedef uint32_t gpio_t; - -typedef enum -{ - gpiolowspeed = 0x00000, - gpiomediumspeed = 0x10000, - gpiofastspeed = 0x20000, - gpiohighspeed = 0x30000 -}gpiospeed_t; - -#define GPIOSPEEDMASK 0x30000 - -typedef enum gpiodir_t -{ - gpioindir = 0x00000, - gpiooutdir = 0x40000, - gpioaf = 0x80000, - gpioan = 0xC0000 -}gpiodir_t; - -#define GPIODIRMASK 0xC0000 - - -typedef enum -{ - gpiopushpulltype = 0x000000, - gpioopendraintype = 0x100000 -}gpioouttype_t; - -#define GPIOOUTTYPEMASK 0x100000 - -typedef enum -{ - gpionopulltype = 0x000000, - gpiopulluptype = 0x200000, - gpiopulldowntype = 0x400000 -}gpiopulltype_t; - -#define GPIOPULLTYPEMASK 0x600000 - -extern gpio_t gpioopen(uint32_t gpio); -extern void gpioclose(gpio_t gpio); -extern void gpiosetconfig(gpio_t* gpio); -extern void gpiosetdir(gpio_t* gpio,gpiodir_t dir); -extern void gpiosetouttype(gpio_t* gpio, gpioouttype_t outtype); -extern void gpiosetpulltype(gpio_t* gpio,gpiopulltype_t pulltype); -extern void gpiosetspeed(gpio_t* gpio,gpiospeed_t speed); -extern void gpioset(gpio_t gpio); -extern void gpioclr(gpio_t gpio); -extern void gpiosetval(gpio_t gpio,int val); -extern int gpiogetval(gpio_t gpio); - -#define GPIOISINPUT(gpio) (((gpio) & GPIODIRMASK)==gpioindir) -#define GPIOISOUTPUT(gpio) (((gpio) & GPIOSPEEDMASK)==gpiooutdir) - -#define GPIOISLOWSPEED(gpio) (((gpio) & GPIOSPEEDMASK)==gpiolowspeed) -#define GPIOISMEDIUMSPEED(gpio) (((gpio) & GPIOSPEEDMASK)==gpiomediumspeed) -#define GPIOISFASTPEED(gpio) (((gpio) & GPIOSPEEDMASK)==gpiofastspeed) -#define GPIOISHIGHSPEED(gpio) (((gpio) & GPIOSPEEDMASK)==gpiohighspeeds) - -#define GPIOISPUSHPULL(gpio) (((gpio) & GPIOOUTTYPEMASK)==gpiopushpulltype) -#define GPIOISOPENDRAIN(gpio) (((gpio) & GPIOOUTTYPEMASK)==gpioopendraintype) - -#define GPIOISNOPULL(GPIO) (((gpio) & GPIOPULLTYPEMASK)==gpionopulltype) -#define GPIOISPULLUP(GPIO) (((gpio) & GPIOPULLTYPEMASK)==gpiopulluptype) -#define GPIOISPULLDOWN(GPIO) (((gpio) & GPIOPULLTYPEMASK)==gpiopulldowntype) - - -#define PA0 ((0<<8)+0) -#define PA1 ((0<<8)+1) -#define PA2 ((0<<8)+2) -#define PA3 ((0<<8)+3) -#define PA4 ((0<<8)+4) -#define PA5 ((0<<8)+5) -#define PA6 ((0<<8)+6) -#define PA7 ((0<<8)+7) -#define PA8 ((0<<8)+8) -#define PA9 ((0<<8)+9) -#define PA10 ((0<<8)+10) -#define PA11 ((0<<8)+11) -#define PA12 ((0<<8)+12) -#define PA13 ((0<<8)+13) -#define PA14 ((0<<8)+14) -#define PA15 ((0<<8)+15) -#define PAX ((0<<8)+255) -#define PB0 ((1<<8)+0) -#define PB1 ((1<<8)+1) -#define PB2 ((1<<8)+2) -#define PB3 ((1<<8)+3) -#define PB4 ((1<<8)+4) -#define PB5 ((1<<8)+5) -#define PB6 ((1<<8)+6) -#define PB7 ((1<<8)+7) -#define PB8 ((1<<8)+8) -#define PB9 ((1<<8)+9) -#define PB10 ((1<<8)+10) -#define PB11 ((1<<8)+11) -#define PB12 ((1<<8)+12) -#define PB13 ((1<<8)+13) -#define PB14 ((1<<8)+14) -#define PB15 ((1<<8)+15) -#define PBX ((1<<8)+255) -#define PC0 ((2<<8)+0) -#define PC1 ((2<<8)+1) -#define PC2 ((2<<8)+2) -#define PC3 ((2<<8)+3) -#define PC4 ((2<<8)+4) -#define PC5 ((2<<8)+5) -#define PC6 ((2<<8)+6) -#define PC7 ((2<<8)+7) -#define PC8 ((2<<8)+8) -#define PC9 ((2<<8)+9) -#define PC10 ((2<<8)+10) -#define PC11 ((2<<8)+11) -#define PC12 ((2<<8)+12) -#define PC13 ((2<<8)+13) -#define PC14 ((2<<8)+14) -#define PC15 ((2<<8)+15) -#define PCX ((2<<8)+255) -#define PD0 ((3<<8)+0) -#define PD1 ((3<<8)+1) -#define PD2 ((3<<8)+2) -#define PD3 ((3<<8)+3) -#define PD4 ((3<<8)+4) -#define PD5 ((3<<8)+5) -#define PD6 ((3<<8)+6) -#define PD7 ((3<<8)+7) -#define PD8 ((3<<8)+8) -#define PD9 ((3<<8)+9) -#define PD10 ((3<<8)+10) -#define PD11 ((3<<8)+11) -#define PD12 ((3<<8)+12) -#define PD13 ((3<<8)+13) -#define PD14 ((3<<8)+14) -#define PD15 ((3<<8)+15) -#define PDX ((3<<8)+255) -#define PE0 ((4<<8)+0) -#define PE1 ((4<<8)+1) -#define PE2 ((4<<8)+2) -#define PE3 ((4<<8)+3) -#define PE4 ((4<<8)+4) -#define PE5 ((4<<8)+5) -#define PE6 ((4<<8)+6) -#define PE7 ((4<<8)+7) -#define PE8 ((4<<8)+8) -#define PE9 ((4<<8)+9) -#define PE10 ((4<<8)+10) -#define PE11 ((4<<8)+11) -#define PE12 ((4<<8)+12) -#define PE13 ((4<<8)+13) -#define PE14 ((4<<8)+14) -#define PE15 ((4<<8)+15) -#define PEX ((4<<8)+255) -#define PF0 ((5<<8)+0) -#define PF1 ((5<<8)+1) -#define PF2 ((5<<8)+2) -#define PF3 ((5<<8)+3) -#define PF4 ((5<<8)+4) -#define PF5 ((5<<8)+5) -#define PF6 ((5<<8)+6) -#define PF7 ((5<<8)+7) -#define PF8 ((5<<8)+8) -#define PF9 ((5<<8)+9) -#define PF10 ((5<<8)+10) -#define PF11 ((5<<8)+11) -#define PF12 ((5<<8)+12) -#define PF13 ((5<<8)+13) -#define PF14 ((5<<8)+14) -#define PF15 ((5<<8)+15) -#define PFX ((5<<8)+255) -#define PG0 ((6<<8)+0) -#define PG1 ((6<<8)+1) -#define PG2 ((6<<8)+2) -#define PG3 ((6<<8)+3) -#define PG4 ((6<<8)+4) -#define PG5 ((6<<8)+5) -#define PG6 ((6<<8)+6) -#define PG7 ((6<<8)+7) -#define PG8 ((6<<8)+8) -#define PG9 ((6<<8)+9) -#define PG10 ((6<<8)+10) -#define PG11 ((6<<8)+11) -#define PG12 ((6<<8)+12) -#define PG13 ((6<<8)+13) -#define PG14 ((6<<8)+14) -#define PG15 ((6<<8)+15) -#define PGX ((6<<8)+255) -#define PH0 ((7<<8)+0) -#define PH1 ((7<<8)+1) -#define PH2 ((7<<8)+2) -#define PH3 ((7<<8)+3) -#define PH4 ((7<<8)+4) -#define PH5 ((7<<8)+5) -#define PH6 ((7<<8)+6) -#define PH7 ((7<<8)+7) -#define PH8 ((7<<8)+8) -#define PH9 ((7<<8)+9) -#define PH10 ((7<<8)+10) -#define PH11 ((7<<8)+11) -#define PH12 ((7<<8)+12) -#define PH13 ((7<<8)+13) -#define PH14 ((7<<8)+14) -#define PH15 ((7<<8)+15) -#define PHX ((7<<8)+255) -#define PI0 ((8<<8)+0) -#define PI1 ((8<<8)+1) -#define PI2 ((8<<8)+2) -#define PI3 ((8<<8)+3) -#define PI4 ((8<<8)+4) -#define PI5 ((8<<8)+5) -#define PI6 ((8<<8)+6) -#define PI7 ((8<<8)+7) -#define PI8 ((8<<8)+8) -#define PI9 ((8<<8)+9) -#define PI10 ((8<<8)+10) -#define PI11 ((8<<8)+11) -#define PI12 ((8<<8)+12) -#define PI13 ((8<<8)+13) -#define PI14 ((8<<8)+14) -#define PI15 ((8<<8)+15) -#define PIX ((8<<8)+255) -#define PJ0 ((9<<8)+0) -#define PJ1 ((9<<8)+1) -#define PJ2 ((9<<8)+2) -#define PJ3 ((9<<8)+3) -#define PJ4 ((9<<8)+4) -#define PJ5 ((9<<8)+5) -#define PJ6 ((9<<8)+6) -#define PJ7 ((9<<8)+7) -#define PJ8 ((9<<8)+8) -#define PJ9 ((9<<8)+9) -#define PJ10 ((9<<8)+10) -#define PJ11 ((9<<8)+11) -#define PJ12 ((9<<8)+12) -#define PJ13 ((9<<8)+13) -#define PJ14 ((9<<8)+14) -#define PJ15 ((9<<8)+15) -#define PJX ((9<<8)+255) -#define PK0 ((10<<8)+0) -#define PK1 ((10<<8)+1) -#define PK2 ((10<<8)+2) -#define PK3 ((10<<8)+3) -#define PK4 ((10<<8)+4) -#define PK5 ((10<<8)+5) -#define PK6 ((10<<8)+6) -#define PK7 ((10<<8)+7) -#define PK8 ((10<<8)+8) -#define PK9 ((10<<8)+9) -#define PK10 ((10<<8)+10) -#define PK11 ((10<<8)+11) -#define PK12 ((10<<8)+12) -#define PK13 ((10<<8)+13) -#define PK14 ((10<<8)+14) -#define PK15 ((10<<8)+15) -#define PKX ((10<<8)+255) -#define PL0 ((11<<8)+0) -#define PL1 ((11<<8)+1) -#define PL2 ((11<<8)+2) -#define PL3 ((11<<8)+3) -#define PL4 ((11<<8)+4) -#define PL5 ((11<<8)+5) -#define PL6 ((11<<8)+6) -#define PL7 ((11<<8)+7) -#define PL8 ((11<<8)+8) -#define PL9 ((11<<8)+9) -#define PL10 ((11<<8)+10) -#define PL11 ((11<<8)+11) -#define PL12 ((11<<8)+12) -#define PL13 ((11<<8)+13) -#define PL14 ((11<<8)+14) -#define PL15 ((11<<8)+15) -#define PLX ((11<<8)+255) -#define PM0 ((12<<8)+0) -#define PM1 ((12<<8)+1) -#define PM2 ((12<<8)+2) -#define PM3 ((12<<8)+3) -#define PM4 ((12<<8)+4) -#define PM5 ((12<<8)+5) -#define PM6 ((12<<8)+6) -#define PM7 ((12<<8)+7) -#define PM8 ((12<<8)+8) -#define PM9 ((12<<8)+9) -#define PM10 ((12<<8)+10) -#define PM11 ((12<<8)+11) -#define PM12 ((12<<8)+12) -#define PM13 ((12<<8)+13) -#define PM14 ((12<<8)+14) -#define PM15 ((12<<8)+15) -#define PMX ((12<<8)+255) -#define PN0 ((13<<8)+0) -#define PN1 ((13<<8)+1) -#define PN2 ((13<<8)+2) -#define PN3 ((13<<8)+3) -#define PN4 ((13<<8)+4) -#define PN5 ((13<<8)+5) -#define PN6 ((13<<8)+6) -#define PN7 ((13<<8)+7) -#define PN8 ((13<<8)+8) -#define PN9 ((13<<8)+9) -#define PN10 ((13<<8)+10) -#define PN11 ((13<<8)+11) -#define PN12 ((13<<8)+12) -#define PN13 ((13<<8)+13) -#define PN14 ((13<<8)+14) -#define PN15 ((13<<8)+15) -#define PNX ((13<<8)+255) -#define PO0 ((14<<8)+0) -#define PO1 ((14<<8)+1) -#define PO2 ((14<<8)+2) -#define PO3 ((14<<8)+3) -#define PO4 ((14<<8)+4) -#define PO5 ((14<<8)+5) -#define PO6 ((14<<8)+6) -#define PO7 ((14<<8)+7) -#define PO8 ((14<<8)+8) -#define PO9 ((14<<8)+9) -#define PO10 ((14<<8)+10) -#define PO11 ((14<<8)+11) -#define PO12 ((14<<8)+12) -#define PO13 ((14<<8)+13) -#define PO14 ((14<<8)+14) -#define PO15 ((14<<8)+15) -#define POX ((14<<8)+255) -#define PP0 ((15<<8)+0) -#define PP1 ((15<<8)+1) -#define PP2 ((15<<8)+2) -#define PP3 ((15<<8)+3) -#define PP4 ((15<<8)+4) -#define PP5 ((15<<8)+5) -#define PP6 ((15<<8)+6) -#define PP7 ((15<<8)+7) -#define PP8 ((15<<8)+8) -#define PP9 ((15<<8)+9) -#define PP10 ((15<<8)+10) -#define PP11 ((15<<8)+11) -#define PP12 ((15<<8)+12) -#define PP13 ((15<<8)+13) -#define PP14 ((15<<8)+14) -#define PP15 ((15<<8)+15) -#define PPX ((15<<8)+255) -#define PQ0 ((16<<8)+0) -#define PQ1 ((16<<8)+1) -#define PQ2 ((16<<8)+2) -#define PQ3 ((16<<8)+3) -#define PQ4 ((16<<8)+4) -#define PQ5 ((16<<8)+5) -#define PQ6 ((16<<8)+6) -#define PQ7 ((16<<8)+7) -#define PQ8 ((16<<8)+8) -#define PQ9 ((16<<8)+9) -#define PQ10 ((16<<8)+10) -#define PQ11 ((16<<8)+11) -#define PQ12 ((16<<8)+12) -#define PQ13 ((16<<8)+13) -#define PQ14 ((16<<8)+14) -#define PQ15 ((16<<8)+15) -#define PQX ((16<<8)+255) -#define PR0 ((17<<8)+0) -#define PR1 ((17<<8)+1) -#define PR2 ((17<<8)+2) -#define PR3 ((17<<8)+3) -#define PR4 ((17<<8)+4) -#define PR5 ((17<<8)+5) -#define PR6 ((17<<8)+6) -#define PR7 ((17<<8)+7) -#define PR8 ((17<<8)+8) -#define PR9 ((17<<8)+9) -#define PR10 ((17<<8)+10) -#define PR11 ((17<<8)+11) -#define PR12 ((17<<8)+12) -#define PR13 ((17<<8)+13) -#define PR14 ((17<<8)+14) -#define PR15 ((17<<8)+15) -#define PRX ((17<<8)+255) -#define PS0 ((18<<8)+0) -#define PS1 ((18<<8)+1) -#define PS2 ((18<<8)+2) -#define PS3 ((18<<8)+3) -#define PS4 ((18<<8)+4) -#define PS5 ((18<<8)+5) -#define PS6 ((18<<8)+6) -#define PS7 ((18<<8)+7) -#define PS8 ((18<<8)+8) -#define PS9 ((18<<8)+9) -#define PS10 ((18<<8)+10) -#define PS11 ((18<<8)+11) -#define PS12 ((18<<8)+12) -#define PS13 ((18<<8)+13) -#define PS14 ((18<<8)+14) -#define PS15 ((18<<8)+15) -#define PSX ((18<<8)+255) -#define PT0 ((19<<8)+0) -#define PT1 ((19<<8)+1) -#define PT2 ((19<<8)+2) -#define PT3 ((19<<8)+3) -#define PT4 ((19<<8)+4) -#define PT5 ((19<<8)+5) -#define PT6 ((19<<8)+6) -#define PT7 ((19<<8)+7) -#define PT8 ((19<<8)+8) -#define PT9 ((19<<8)+9) -#define PT10 ((19<<8)+10) -#define PT11 ((19<<8)+11) -#define PT12 ((19<<8)+12) -#define PT13 ((19<<8)+13) -#define PT14 ((19<<8)+14) -#define PT15 ((19<<8)+15) -#define PTX ((19<<8)+255) -#define PU0 ((20<<8)+0) -#define PU1 ((20<<8)+1) -#define PU2 ((20<<8)+2) -#define PU3 ((20<<8)+3) -#define PU4 ((20<<8)+4) -#define PU5 ((20<<8)+5) -#define PU6 ((20<<8)+6) -#define PU7 ((20<<8)+7) -#define PU8 ((20<<8)+8) -#define PU9 ((20<<8)+9) -#define PU10 ((20<<8)+10) -#define PU11 ((20<<8)+11) -#define PU12 ((20<<8)+12) -#define PU13 ((20<<8)+13) -#define PU14 ((20<<8)+14) -#define PU15 ((20<<8)+15) -#define PUX ((20<<8)+255) -#define PV0 ((21<<8)+0) -#define PV1 ((21<<8)+1) -#define PV2 ((21<<8)+2) -#define PV3 ((21<<8)+3) -#define PV4 ((21<<8)+4) -#define PV5 ((21<<8)+5) -#define PV6 ((21<<8)+6) -#define PV7 ((21<<8)+7) -#define PV8 ((21<<8)+8) -#define PV9 ((21<<8)+9) -#define PV10 ((21<<8)+10) -#define PV11 ((21<<8)+11) -#define PV12 ((21<<8)+12) -#define PV13 ((21<<8)+13) -#define PV14 ((21<<8)+14) -#define PV15 ((21<<8)+15) -#define PVX ((21<<8)+255) -#define PW0 ((22<<8)+0) -#define PW1 ((22<<8)+1) -#define PW2 ((22<<8)+2) -#define PW3 ((22<<8)+3) -#define PW4 ((22<<8)+4) -#define PW5 ((22<<8)+5) -#define PW6 ((22<<8)+6) -#define PW7 ((22<<8)+7) -#define PW8 ((22<<8)+8) -#define PW9 ((22<<8)+9) -#define PW10 ((22<<8)+10) -#define PW11 ((22<<8)+11) -#define PW12 ((22<<8)+12) -#define PW13 ((22<<8)+13) -#define PW14 ((22<<8)+14) -#define PW15 ((22<<8)+15) -#define PWX ((22<<8)+255) -#define PX0 ((23<<8)+0) -#define PX1 ((23<<8)+1) -#define PX2 ((23<<8)+2) -#define PX3 ((23<<8)+3) -#define PX4 ((23<<8)+4) -#define PX5 ((23<<8)+5) -#define PX6 ((23<<8)+6) -#define PX7 ((23<<8)+7) -#define PX8 ((23<<8)+8) -#define PX9 ((23<<8)+9) -#define PX10 ((23<<8)+10) -#define PX11 ((23<<8)+11) -#define PX12 ((23<<8)+12) -#define PX13 ((23<<8)+13) -#define PX14 ((23<<8)+14) -#define PX15 ((23<<8)+15) -#define PXX ((23<<8)+255) -#define PY0 ((24<<8)+0) -#define PY1 ((24<<8)+1) -#define PY2 ((24<<8)+2) -#define PY3 ((24<<8)+3) -#define PY4 ((24<<8)+4) -#define PY5 ((24<<8)+5) -#define PY6 ((24<<8)+6) -#define PY7 ((24<<8)+7) -#define PY8 ((24<<8)+8) -#define PY9 ((24<<8)+9) -#define PY10 ((24<<8)+10) -#define PY11 ((24<<8)+11) -#define PY12 ((24<<8)+12) -#define PY13 ((24<<8)+13) -#define PY14 ((24<<8)+14) -#define PY15 ((24<<8)+15) -#define PYX ((24<<8)+255) -#define PZ0 ((25<<8)+0) -#define PZ1 ((25<<8)+1) -#define PZ2 ((25<<8)+2) -#define PZ3 ((25<<8)+3) -#define PZ4 ((25<<8)+4) -#define PZ5 ((25<<8)+5) -#define PZ6 ((25<<8)+6) -#define PZ7 ((25<<8)+7) -#define PZ8 ((25<<8)+8) -#define PZ9 ((25<<8)+9) -#define PZ10 ((25<<8)+10) -#define PZ11 ((25<<8)+11) -#define PZ12 ((25<<8)+12) -#define PZ13 ((25<<8)+13) -#define PZ14 ((25<<8)+14) -#define PZ15 ((25<<8)+15) -#define PZX ((25<<8)+255) - - -#ifdef __cplusplus - } -#endif -#endif //GPIO_H - - - - - - - - - - - - diff --git a/include/hexviewer.h b/include/hexviewer.h deleted file mode 100644 --- a/include/hexviewer.h +++ /dev/null @@ -1,52 +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@gmail.com -#-------------------------------------------------------------------------------*/ -#ifndef HEXVIEWER_H -#define HEXVIEWER_H - -#include - - - - -extern void hexviewershow(const char* table,unsigned int size,unsigned int offset); - - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/include/i2c.h b/include/i2c.h deleted file mode 100644 --- a/include/i2c.h +++ /dev/null @@ -1,74 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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@gmail.com --------------------------------------------------------------------------------*/ -#ifndef I2C_H -#define I2C_H -#include -#include -#include - -#ifdef __cplusplus - extern "C" { -#endif - -typedef int i2c_t; - -#define i2c1 0 -#define i2c2 1 -#define i2c3 2 -#define i2c4 3 -#define i2c5 4 -#define i2c6 5 -#define i2c7 6 -#define i2c8 7 -#define i2c9 8 - -extern int i2ctimeout; - -extern i2c_t i2copen(int count); -extern i2c_t i2copenandconfig(int count ,uint32_t cfg,uint32_t speed,uint32_t SDA,uint32_t SCL); -extern int i2cclose(i2c_t dev); -extern int i2csetpins(i2c_t dev,uint32_t SDA,uint32_t SCL); -extern int i2cenable(i2c_t dev); -extern int i2cdisable(i2c_t dev); -//extern int i2csetconfig(i2c_t dev); -extern int i2csetspeed(i2c_t dev,uint32_t speed); -//extern int i2csetdatabits(i2c_t* dev,uartbits_t databits); -extern int i2cwrite(i2c_t dev,char address,char* data,int count); -extern int i2cread(i2c_t dev,char address,char* data,int count); -extern int i2cbusy(i2c_t dev); -extern int i2cStatusCheck(i2c_t dev,int32_t flagMask); -#ifdef __cplusplus - } -#endif -#endif //I2C_H - - - - - - - - - - - - diff --git a/include/ina226.h b/include/ina226.h deleted file mode 100644 --- a/include/ina226.h +++ /dev/null @@ -1,104 +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@gmail.com --------------------------------------------------------------------------------*/ -#ifndef INA226_H -#define INA226_H - -#include -#include - -typedef struct INA226_t -{ - i2c_t i2cdev; - uint8_t devAddress; - uint32_t shuntmOhm; - uint32_t CurrentRangeuAmp; -}INA226_t; - -extern int ina226open(INA226_t* dev,i2c_t i2cdev,uint16_t config,uint8_t A0,uint8_t A1,uint32_t shuntmOhm, uint32_t CurrentRangeuAmp); -extern uint16_t ina226getID(INA226_t* dev); -extern int ina226calibrate(INA226_t* dev,uint32_t shuntmOhm, uint32_t CurrentRangeuAmp); -extern uint32_t ina226getBusVoltage(INA226_t* dev); -extern uint32_t ina226getPower(INA226_t* dev); -extern int32_t ina226getCurrent(INA226_t* dev); -extern uint16_t ina226getReg(INA226_t* dev,char reg); -extern int ina226setReg(INA226_t* dev,char reg,int16_t value); - - -#define INA226_I2C_ADDRESS 0x40 - - -#define INA226_Die_ID_Reg 0xFF -#define INA226_Configuration_Reg 0 -#define INA226_Shunt_Voltage_Reg 1 -#define INA226_Bus_Voltage_Reg 2 -#define INA226_Power_Reg 3 -#define INA226_Current_Reg 4 -#define INA226_Calibration_Reg 5 -#define INA226_Mask_Enable_Reg 6 -#define INA226_Alert_Limit_Reg 7 - -#define INA226_AVERAGES_1 0 -#define INA226_AVERAGES_4 (1<<9) -#define INA226_AVERAGES_16 (2<<9) -#define INA226_AVERAGES_64 (3<<9) -#define INA226_AVERAGES_128 (4<<9) -#define INA226_AVERAGES_256 (5<<9) -#define INA226_AVERAGES_512 (6<<9) -#define INA226_AVERAGES_1024 (7<<9) - -#define INA226_BUS_CONV_140us 0 -#define INA226_BUS_CONV_204us (1<<6) -#define INA226_BUS_CONV_332us (2<<6) -#define INA226_BUS_CONV_588us (3<<6) -#define INA226_BUS_CONV_1100us (4<<6) -#define INA226_BUS_CONV_2116us (5<<6) -#define INA226_BUS_CONV_4156us (6<<6) -#define INA226_BUS_CONV_8244us (7<<6) - -#define INA226_SHUNT_CONV_140us 0 -#define INA226_SHUNT_CONV_204us (1<<3) -#define INA226_SHUNT_CONV_332us (2<<3) -#define INA226_SHUNT_CONV_588us (3<<3) -#define INA226_SHUNT_CONV_1100us (4<<3) -#define INA226_SHUNT_CONV_2116us (5<<3) -#define INA226_SHUNT_CONV_4156us (6<<3) -#define INA226_SHUNT_CONV_8244us (7<<3) - -#define INA226_MODE_POWER_DOWN 0 -#define INA226_MODE_SHUNT_VOLTAGE_TRIGGERRED 1 -#define INA226_MODE_BUS_VOLTAGE_TRIGGERRED 2 -#define INA226_MODE_SHUNT_AND_BUS_TRIGGERRED 3 -#define INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS 5 -#define INA226_MODE_BUS_VOLTAGE_CONTINUOUS 6 -#define INA226_MODE_SHUNT_AND_BUS_CONTINUOUS 7 - - - - -#endif - - - - - - - diff --git a/include/libucfs.h b/include/libucfs.h deleted file mode 100644 --- a/include/libucfs.h +++ /dev/null @@ -1,78 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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@gmail.com --------------------------------------------------------------------------------*/ -#ifndef FS_H -#define FS_H -#include -#include - -struct fs_str -{ - UHANDLE fat; -}; - -typedef struct fs_str filesys_t; - - - -#endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/include/libucstrings.h b/include/libucstrings.h deleted file mode 100644 --- a/include/libucstrings.h +++ /dev/null @@ -1,32 +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@gmail.com -#-------------------------------------------------------------------------------*/ - -#include - -extern streamdevice* stdo; - -void clearstr(char* a); -void int2hex(unsigned long a,char*b); -int libucprintf(const char* format,...); -int libucfprintf(streamdevice* device,const char* format,...); -int libucscanf(const char*,...); -void libucprintchartable(char* table,int size,const char* format,const char* separator); diff --git a/include/mbr.h b/include/mbr.h deleted file mode 100644 --- a/include/mbr.h +++ /dev/null @@ -1,72 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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 MBR_H -#define MBR_H -#include -#include - -#define BootFlagoffset 0 -#define TypeCodeoffset 4 -#define LBABeginoffset 8 -#define NumOfSecoffset 12 - -#define MBRBadMbr 1 -#define MBRBabArg 2 -#define MBRReadErr 3 -#define MBRnoErr 0 - -#define isFat32(TypeCode) (((TypeCode)==0x0b)||((TypeCode)==0x0c)) - -typedef struct dikpartition -{ - char TypeCode; - char valide; - unsigned int LBABegin; - unsigned int NumOfSec; - blkdevice* phy; -}dikpartition; - - -int mbropen(blkdevice* phy,dikpartition* part,char partNum); - - -#endif - - - - - - - - - - - - - - - - - - - - diff --git a/include/sdcard-sdio.h b/include/sdcard-sdio.h deleted file mode 100644 --- a/include/sdcard-sdio.h +++ /dev/null @@ -1,65 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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@gmail.com --------------------------------------------------------------------------------*/ -#ifndef SDCARD-SDIO_H -#define SDCARD-SDIO_H -#include -#include -#include -#include - -extern void sdcardsdiomake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)); -extern void sdcardsdiomakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected); - - -#endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/include/sdcard-spi.h b/include/sdcard-spi.h deleted file mode 100644 --- a/include/sdcard-spi.h +++ /dev/null @@ -1,66 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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@gmail.com --------------------------------------------------------------------------------*/ -#ifndef SDCARD_SPI_H -#define SDCARD_SPI_H -#include -#include -#include -#include - - -extern void sdcardspimake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)); -extern void sdcardspimakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected); - - -#endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/include/sdcard.h b/include/sdcard.h deleted file mode 100644 --- a/include/sdcard.h +++ /dev/null @@ -1,106 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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 SDCARD_H -#define SDCARD_H -#include "blkdevice.h" -#include -#include - -/* MMC/SD command */ -#define CMD0 (0) /* GO_IDLE_STATE */ -#define CMD1 (1) /* SEND_OP_COND (MMC) */ -#define ACMD41 (0x80+41) /* SEND_OP_COND (SDC) */ -#define CMD8 (8) /* SEND_IF_COND */ -#define CMD9 (9) /* SEND_CSD */ -#define CMD10 (10) /* SEND_CID */ -#define CMD12 (12) /* STOP_TRANSMISSION */ -#define ACMD13 (0x80+13) /* SD_STATUS (SDC) */ -#define CMD16 (16) /* SET_BLOCKLEN */ -#define CMD17 (17) /* READ_SINGLE_BLOCK */ -#define CMD18 (18) /* READ_MULTIPLE_BLOCK */ -#define CMD23 (23) /* SET_BLOCK_COUNT (MMC) */ -#define ACMD23 (0x80+23) /* SET_WR_BLK_ERASE_COUNT (SDC) */ -#define CMD24 (24) /* WRITE_BLOCK */ -#define CMD25 (25) /* WRITE_MULTIPLE_BLOCK */ -#define CMD32 (32) /* ERASE_ER_BLK_START */ -#define CMD33 (33) /* ERASE_ER_BLK_END */ -#define CMD38 (38) /* ERASE */ -#define CMD55 (55) /* APP_CMD */ -#define CMD58 (58) /* READ_OCR */ - -/* Card type flags (CardType) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - -struct sdcard_str -{ - UHANDLE phy; - int (*rcvr_mmc) (UHANDLE phy,char *buff,uint32_t bc); - int (*xmit_mmc) (UHANDLE phy,const char *buff,uint32_t bc); - int (*setspeed) (UHANDLE phy,uint32_t speed); - uint32_t (*getspeed) (UHANDLE phy); - DSTATUS Stat; - char CardType; -}; - -typedef volatile struct sdcard_str sdcardDev; - -//extern void sdcardmake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)); -//extern void sdcardmakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected); - - -#endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/include/spi.h b/include/spi.h deleted file mode 100644 --- a/include/spi.h +++ /dev/null @@ -1,151 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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 --------------------------------------------------------------------------------*/ -/* - TODO: - Add SPI slave mode - Add interrupt interface -*/ - -#ifndef SPI_H -#define SPI_H -#include -#include - -#ifdef __cplusplus - extern "C" { -#endif - -/* -typedef struct spi_t -{ - void* _dev; - int cfg; - int speed; -}spi_t;*/ - -typedef int spi_t; - - #define spi1 ((spi_t)0) - #define spi2 ((spi_t)1) - #define spi3 ((spi_t)2) - #define spi4 ((spi_t)3) - #define spi5 ((spi_t)4) - #define spi6 ((spi_t)5) - #define spi7 ((spi_t)6) - #define spi8 ((spi_t)7) - #define spi9 ((spi_t)8) - - -typedef enum -{ - spi4bits = 0x3, - spi5bits = 0x4, - spi6bits = 0x5, - spi7bits = 0x6, - spi8bits = 0x7, - spi9bits = 0x8, - spi10bits = 0x9, - spi11bits = 0xA, - spi12bits = 0xB, - spi13bits = 0xC, - spi14bits = 0xD, - spi15bits = 0xE, - spi16bits = 0xF -}spibits_t; - -#define SPIBITSMASK 0xF - -typedef enum -{ - spislave = 0x00, - spimaster = 0x10 -}spimode_t; - -#define SPIMODEMASK 0x10 - -typedef enum -{ - spiclkinhlow = 0x00, - spiclkinhhigh = 0x20 -}spiclkinhlvl_t; - -#define SPICLKINHLVLMASK 0x20 - - -typedef enum -{ - spiclkfirstedge = 0x00, - spiclksecondedge = 0x40 -}spiclkphase_t; - -#define SPICLKPHASEMASK 0x40 - -typedef enum -{ - spimsbfirst = 0x00, - spilsbfirst = 0x80 -}spibitorder_t; - -#define SPIBITORDERMASK 0x80 - - -extern spi_t spiopen(int count); -extern spi_t spiopenandconfig(int count,uint32_t cfg,uint32_t speed,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin); -extern int spiclose(spi_t spidev); -extern int spisetpins(spi_t spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin); -extern int spienable(spi_t spidev); -extern int spidisable(spi_t spidev); -extern int spitransactionfinished(spi_t spidev); -extern int spisetconfig(spi_t spidev,uint32_t config,uint32_t speed); -extern int spisetspeed(spi_t spidev, uint32_t speed); -extern uint32_t spigetspeed(spi_t spidev); -extern int spisetbitorder(spi_t spidev,spibitorder_t order); -extern int spisetdatabits(spi_t spidev,spibits_t bitscnt); -extern int spisetclkinhlevel(spi_t spidev,spiclkinhlvl_t level); -extern int spisetclkphase(spi_t spidev,spiclkphase_t phase); -extern int spiputw(spi_t spidev,uint16_t data); -extern uint16_t spigetw(spi_t spidev); -extern uint16_t spigetw2(spi_t spidev,uint16_t data); -extern int spiputs(spi_t spidev,char* s); -extern int spigets(spi_t spidev,char* s); -extern int spiputnw(spi_t spidev,uint16_t* w,int n); -extern int spigetnw(spi_t spidev,uint16_t* w,int n); -extern int spiputnc(spi_t spidev,char* c,int n); -extern int spigetnc(spi_t spidev,char* c,int n); -extern int spiavailiabledata(spi_t spidev); - -#ifdef __cplusplus - } -#endif -#endif //SPI_H - - - - - - - - - - - - diff --git a/include/streamdevices.h b/include/streamdevices.h --- a/include/streamdevices.h +++ b/include/streamdevices.h @@ -22,7 +22,6 @@ #ifndef STREAMDEVICES_H #define STREAMDEVICES_H #include -#include typedef struct streamdevice* streamdeviceptr; struct streamdevice_ops; diff --git a/include/thread.h b/include/thread.h --- a/include/thread.h +++ b/include/thread.h @@ -22,8 +22,6 @@ #ifndef THREAD_H #define THREAD_H #include -#include -#include #ifdef __cplusplus extern "C" { diff --git a/include/uart.h b/include/uart.h deleted file mode 100644 --- a/include/uart.h +++ /dev/null @@ -1,118 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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@gmail.com --------------------------------------------------------------------------------*/ -#ifndef UART_H -#define UART_H -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* -typedef volatile struct uart_t -{ - volatile void* _dev; - volatile int cfg; - volatile int speed; -}uart_t; - */ - -typedef int uart_t; -#define uart1 0 -#define uart2 1 -#define uart3 2 -#define uart4 3 -#define uart5 4 -#define uart6 5 -#define uart7 6 -#define uart8 7 -#define uart9 8 - - -typedef enum -{ - uartparitynone = 0x1, - uartparityeven = 0x2, - uartparityodd = 0x3 -}uartparity_t; - -#define UARTPARITYMASK 0x3 - -typedef enum -{ - uart7bits = 0x4, - uart8bits = 0x8, - uart9bits = 0xC -}uartbits_t; - -#define UARTBITSMASK 0xC - - -typedef enum -{ - uarthalfstop = 0x10, - uartonestop = 0x20, - uartonehalfstop = 0x30, - uarttwostop = 0x40 -}uartstopbits_t; - -#define UARTSTOPBITSMASK 0x70 - -extern uart_t uartopen(int count); -extern uart_t uartopenandconfig(int count ,uint32_t cfg,uint32_t speed,uint32_t TXpin,uint32_t RXpin,uint32_t RTSpin,uint32_t CTSpin); -extern int uartclose(uart_t uart); -extern int uartsetpins(uart_t uart,uint32_t TXpin,uint32_t RXpin,uint32_t RTSpin,uint32_t CTSpin); -extern int uartenable(uart_t uart); -extern int uartdisable(uart_t uart); -extern int uartsetconfig(uart_t uart,uint32_t cfg,uint32_t speed); -extern int uartsetspeed(uart_t uart,uint32_t speed); -extern int uartsetparity(uart_t uart,uartparity_t parity); -extern int uartsetdatabits(uart_t uart,uartbits_t databits); -extern int uartsetstopbits(uart_t uart,uartstopbits_t stopbits); -extern int uartputc(uart_t uart,char c); -extern char uartgetc(uart_t uart); -extern int uartputs(uart_t uart,char* s); -extern int uartgets(uart_t uart,char* s); -extern int uartputnc(uart_t uart,char* c,int n); -extern int uartgetnc(uart_t uart,char* c,int n); -extern int uartavailiabledata(uart_t uart); - -extern int uartmkstreamdev(uart_t uart,streamdevice* strdev); - -#ifdef __cplusplus -} -#endif -#endif //SPI_H - - - - - - - - - - - - diff --git a/include/ucdirent.h b/include/ucdirent.h deleted file mode 100644 --- a/include/ucdirent.h +++ /dev/null @@ -1,134 +0,0 @@ -/*------------------------------------------------------------------------------ --- This file is a part of the libuc, microcontroler library --- Copyright (C) 2012, 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@gmail.com --------------------------------------------------------------------------------*/ -#ifndef UCDIRENT_H -#define UCDIRENT_H -#include -#include -#include -#include -//#include - -#define ATTR_READ_ONLY 0x01 -#define ATTR_HIDDEN 0x02 -#define ATTR_SYSTEM 0x04 -#define ATTR_VOLUME_ID 0x08 -#define ATTR_DIRECTORY 0x10 -#define ATTR_ARCHIVE 0x20 -#define ATTR_LONGNAME 0x0F - -#define DIRENT_EndOfDir 1 -#define DIRENT_BabArg 2 -#define DIRENT_ReadErr 3 -#define DIRENT_LastSect 4 -#define DIRENT_BadSect 5 -#define DIRENT_noErr 0 - -typedef struct ucdirent* ucdirentptr; -typedef int (*getrootfirstent_t)(ucdirentptr entry); -typedef int (*nextdirent_t)(ucdirentptr entry); -typedef int (*getname_t)(ucdirentptr entry,char* name); - -typedef struct dirent -{ - unsigned char DIR_Name[16]; - unsigned char DIR_Attr; - unsigned char DIR_CrtTimeTenth; - unsigned short DIR_CrtTime; - unsigned short DIR_CrtDate; - unsigned short DIR_LstAccDate; - unsigned short DIR_FstClusHI; - unsigned short DIR_WrtTime; - unsigned short DIR_WrtDate; - unsigned short DIR_FstClustLO; - unsigned int DIR_FileSize; - unsigned int CurrentSec; - unsigned char Currententry; - UHANDLE fs; - getrootfirstent_t getrootfirstent; - nextdirent_t nextdirent; - getname_t getname; -}dirent; - -typedef struct ucdirent{ - uint8_t DIR_Name[16]; - uint8_t DIR_Attr; - uint8_t DIR_CrtTimeTenth; - uint16_t DIR_CrtTime; - uint16_t DIR_CrtDate; - uint16_t DIR_LstAccDate; - uint16_t DIR_FstClusHI; - uint16_t DIR_WrtTime; - uint16_t DIR_WrtDate; - uint16_t DIR_FstClustLO; - uint32_t DIR_FileSize; - uint32_t CurrentSec; - uint8_t Currententry; - UHANDLE fs; - getrootfirstent_t getrootfirstent; - nextdirent_t nextdirent; - getname_t getname; -}ucdirent; - - - -#define direntgetroot(dirent) (dirent).getrootfirstent(&dirent) -#define direntgetnext(dirent) (dirent).nextdirent(&dirent) - -#endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/include/uhandle.h b/include/uhandle.h --- a/include/uhandle.h +++ b/include/uhandle.h @@ -21,7 +21,7 @@ -------------------------------------------------------------------------------*/ #ifndef UHANDLE_H #define UHANDLE_H - +#include typedef volatile void* UHANDLE; #define uhandlevalide(HANDLE) ((HANDLE)!=0) diff --git a/mkspecs/features/libuc2.prf b/mkspecs/features/libuc2.prf --- a/mkspecs/features/libuc2.prf +++ b/mkspecs/features/libuc2.prf @@ -18,10 +18,17 @@ defineTest(copyFiles) { } INCLUDEPATH += $$[QT_INSTALL_HEADERS] \ + $$[QT_INSTALL_HEADERS]/FS \ + $$[QT_INSTALL_HEADERS]/EEPROMS \ + $$[QT_INSTALL_HEADERS]/AUDIO \ + $$[QT_INSTALL_HEADERS]/POWER \ + $$[QT_INSTALL_HEADERS]/PERIPHERALS \ + $$[QT_INSTALL_HEADERS]/FLASH \ + $$[QT_INSTALL_HEADERS]/ADC \ $$[QT_INSTALL_HEADERS]/GRAPHIC/CONTROLERS \ $$[QT_INSTALL_HEADERS]/GRAPHIC/TC_CONTROLERS \ - $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/FONTS \ - $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/Widgets + $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/FONTS \ + $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/Widgets # # Microcontroler switch diff --git a/src/common/AUDIO/VS10XX/VS10XX_SIMULATOR.pro b/src/common/AUDIO/VS10XX/VS10XX_SIMULATOR.pro --- a/src/common/AUDIO/VS10XX/VS10XX_SIMULATOR.pro +++ b/src/common/AUDIO/VS10XX/VS10XX_SIMULATOR.pro @@ -6,4 +6,7 @@ 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 --- a/src/common/AUDIO/VS10XX/VS10XX_STM32F4.pro +++ b/src/common/AUDIO/VS10XX/VS10XX_STM32F4.pro @@ -7,3 +7,7 @@ SOURCES += VS10XX.c UCMODEL=stm32f4 +HEADERS += \ + ../../../../include/AUDIO/VS10XX.h + + diff --git a/src/common/POWER/ina226/ina226_SIMULATOR.pro b/src/common/POWER/ina226/ina226_SIMULATOR.pro --- a/src/common/POWER/ina226/ina226_SIMULATOR.pro +++ b/src/common/POWER/ina226/ina226_SIMULATOR.pro @@ -6,3 +6,6 @@ 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 --- a/src/common/POWER/ina226/ina226_STM32F4.pro +++ b/src/common/POWER/ina226/ina226_STM32F4.pro @@ -6,3 +6,6 @@ SOURCES += ina226.c UCMODEL=stm32f4 +HEADERS += \ + ../../../../include/POWER/ina226.h + diff --git a/src/simulator/SDLCD/SDLCD.c b/src/simulator/SDLCD/SDLCD.c --- a/src/simulator/SDLCD/SDLCD.c +++ b/src/simulator/SDLCD/SDLCD.c @@ -22,7 +22,7 @@ #include #include -#include "SDLCD.h" +#include SDL_Surface *screen; SDL_Overlay *bmp; diff --git a/src/stm32f4/CORE/irq_handlers.c b/src/stm32f4/CORE/irq_handlers.c --- a/src/stm32f4/CORE/irq_handlers.c +++ b/src/stm32f4/CORE/irq_handlers.c @@ -29,7 +29,7 @@ void UsageFault_Handler(void) void SVC_Handler(void) { // __set_CONTROL(2); - // printf("SVC_Handler\n"); + printf("SVC_Handler\n"); } void DebugMon_Handler(void) diff --git a/src/stm32f4/GPIO/gpio.pro b/src/stm32f4/GPIO/gpio.pro --- a/src/stm32f4/GPIO/gpio.pro +++ b/src/stm32f4/GPIO/gpio.pro @@ -5,6 +5,9 @@ SOURCES += gpio.c UCMODEL=stm32f4 +HEADERS += \ + ../../../include/PERIPHERALS/gpio.h + diff --git a/src/stm32f4/I2C/i2c.pro b/src/stm32f4/I2C/i2c.pro --- a/src/stm32f4/I2C/i2c.pro +++ b/src/stm32f4/I2C/i2c.pro @@ -6,5 +6,8 @@ SOURCES += i2c.c UCMODEL=stm32f4 +HEADERS += \ + ../../../include/PERIPHERALS/i2c.h + diff --git a/src/stm32f4/SDCARD-SDIO/sdcard-sdio.pro b/src/stm32f4/SDCARD-SDIO/sdcard-sdio.pro --- a/src/stm32f4/SDCARD-SDIO/sdcard-sdio.pro +++ b/src/stm32f4/SDCARD-SDIO/sdcard-sdio.pro @@ -4,3 +4,6 @@ CONFIG += libuc2lib SOURCES += sdcard-sdio.c UCMODEL=stm32f4 + +HEADERS += \ + ../../../include/FLASH/sdcard-sdio.h diff --git a/src/stm32f4/SPI/spi.pro b/src/stm32f4/SPI/spi.pro --- a/src/stm32f4/SPI/spi.pro +++ b/src/stm32f4/SPI/spi.pro @@ -6,3 +6,6 @@ SOURCES += spi.c UCMODEL=stm32f4 +HEADERS += \ + ../../../include/PERIPHERALS/spi.h + diff --git a/src/stm32f4/UART/uart.pro b/src/stm32f4/UART/uart.pro --- a/src/stm32f4/UART/uart.pro +++ b/src/stm32f4/UART/uart.pro @@ -4,3 +4,7 @@ CONFIG += libuc2lib SOURCES += uart.c UCMODEL=stm32f4 + +HEADERS += \ + ../../../include/PERIPHERALS/uart.h +