@@ -0,0 +1,101 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2012, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@gmail.com | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef UART_H | |
|
23 | #define UART_H | |
|
24 | #include <stdint.h> | |
|
25 | #include <uhandle.h> | |
|
26 | ||
|
27 | #ifdef __cplusplus | |
|
28 | extern "C" { | |
|
29 | #endif | |
|
30 | ||
|
31 | ||
|
32 | typedef struct uart_str uart_t; | |
|
33 | ||
|
34 | struct uart_str{ | |
|
35 | void* _dev; | |
|
36 | int cfg; | |
|
37 | int speed; | |
|
38 | }; | |
|
39 | ||
|
40 | typedef enum | |
|
41 | { | |
|
42 | uartparitynone = 0x1, | |
|
43 | uartparityeven = 0x2, | |
|
44 | uartparityodd = 0x3 | |
|
45 | }uartparity_t; | |
|
46 | ||
|
47 | #define UARTPARITYMASK 0x3 | |
|
48 | ||
|
49 | typedef enum | |
|
50 | { | |
|
51 | uart7bits = 0x4, | |
|
52 | uart8bits = 0x8, | |
|
53 | uart9bits = 0xC | |
|
54 | }uartbits_t; | |
|
55 | ||
|
56 | #define UARTBITSMASK 0xC | |
|
57 | ||
|
58 | ||
|
59 | typedef enum | |
|
60 | { | |
|
61 | uarthalfstop = 0x10, | |
|
62 | uartonestop = 0x20, | |
|
63 | uartonehalfstop = 0x30, | |
|
64 | uarttwostop = 0x40 | |
|
65 | }uartstopbits_t; | |
|
66 | ||
|
67 | #define UARTSTOPBITSMASK 0x70 | |
|
68 | ||
|
69 | extern int uartopen(int,uart_t*); | |
|
70 | extern int uartclose(uart_t*); | |
|
71 | extern int uartenable(uart_t*); | |
|
72 | extern int uartdisable(uart_t*); | |
|
73 | extern int uartsetconfig(uart_t*); | |
|
74 | extern int uartsetspeed(uart_t*,int); | |
|
75 | extern int uartsetparity(uart_t*,uartparity_t); | |
|
76 | extern int uartsetdatabits(uart_t*,uartbits_t); | |
|
77 | extern int uartsetstopbits(uart_t*,uartstopbits_t); | |
|
78 | extern int uartputc(uart_t*,char); | |
|
79 | extern char uartgetc(uart_t*); | |
|
80 | extern int uartputs(uart_t*,char*); | |
|
81 | extern int uartgets(uart_t*,char*); | |
|
82 | extern int uartputnc(uart_t*,char*,int); | |
|
83 | extern int uartgetnc(uart_t*,char*,int); | |
|
84 | extern int uartavailiabledata(uart_t*); | |
|
85 | ||
|
86 | #ifdef __cplusplus | |
|
87 | } | |
|
88 | #endif | |
|
89 | #endif //GPIO_H | |
|
90 | ||
|
91 | ||
|
92 | ||
|
93 | ||
|
94 | ||
|
95 | ||
|
96 | ||
|
97 | ||
|
98 | ||
|
99 | ||
|
100 | ||
|
101 |
@@ -1,174 +1,178 | |||
|
1 | 1 | #!/bin/bash |
|
2 | 2 | #/*------------------------------------------------------------------------------ |
|
3 | 3 | #-- This file is a part of the libuc, microcontroler library |
|
4 | 4 | #-- Copyright (C) 2011, Alexis Jeandet |
|
5 | 5 | #-- |
|
6 | 6 | #-- This program is free software; you can redistribute it and/or modify |
|
7 | 7 | #-- it under the terms of the GNU General Public License as published by |
|
8 | 8 | #-- the Free Software Foundation; either version 3 of the License, or |
|
9 | 9 | #-- (at your option) any later version. |
|
10 | 10 | #-- |
|
11 | 11 | #-- This program is distributed in the hope that it will be useful, |
|
12 | 12 | #-- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | 13 | #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | 14 | #-- GNU General Public License for more details. |
|
15 | 15 | #-- |
|
16 | 16 | #-- You should have received a copy of the GNU General Public License |
|
17 | 17 | #-- along with this program; if not, write to the Free Software |
|
18 | 18 | #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
19 | 19 | #------------------------------------------------------------------------------- |
|
20 | 20 | #-- Author : Alexis Jeandet |
|
21 | 21 | #-- Mail : alexis.jeandet@gmail.com |
|
22 | 22 | #-------------------------------------------------------------------------------*/ |
|
23 | 23 | |
|
24 | 24 | function template-run { |
|
25 | 25 | Targets $PROJECTFILE |
|
26 | 26 | if [ -z "$TARGETS" ] ; then |
|
27 | 27 | echo "Single Target" |
|
28 | 28 | Target $PROJECTFILE |
|
29 | 29 | Arch $PROJECTFILE |
|
30 | 30 | Objdir $PROJECTFILE |
|
31 | 31 | Bindir $PROJECTFILE |
|
32 | 32 | Libs_Inc $PROJECTFILE |
|
33 | 33 | Libs_Link $PROJECTFILE |
|
34 | 34 | HeadersInstallPath $PROJECTFILE |
|
35 | 35 | TargetInstallPath $PROJECTFILE |
|
36 | 36 | getBSP $PROJECTFILE |
|
37 | 37 | ExtractCFLAGS $PROJECTFILE |
|
38 | 38 | ExtractLDFLAGS $PROJECTFILE |
|
39 | 39 | ExtractODFLAGS $PROJECTFILE |
|
40 | 40 | echo "Current BSP is $BSP" |
|
41 | 41 | echo $SRCFILES >> Makefile |
|
42 | 42 | getFilesList $PROJECTFILE HEADERS >> Makefile |
|
43 | 43 | getFilesList $PROJECTFILE SOURCES | sed 's/SOURCES/LIBSOURCES/' >> Makefile |
|
44 | 44 | |
|
45 | 45 | echo "=========================================================================" |
|
46 | 46 | echo " M A K E F I L E G E N E R A T I O N " |
|
47 | 47 | echo "-------------------------------------------------------------------------" |
|
48 | 48 | echo " Template = library " |
|
49 | 49 | echo " Architecture = $ARCH " |
|
50 | 50 | echo " Output file = $TARGET " |
|
51 | 51 | echo "=========================================================================" |
|
52 | 52 | echo "" |
|
53 | 53 | echo " Start Writing Makefile ..." |
|
54 | 54 | echo "OBJDIR = $OBJDIR" >> Makefile |
|
55 | 55 | echo "BINDIR = $BINDIR" >> Makefile |
|
56 | 56 | echo 'OBJECTFILES = $(LIBSOURCES:.c=.o)'>> Makefile |
|
57 | 57 | echo 'OBJECTFILES := $(addprefix $(OBJDIR)/,$(OBJECTFILES))'>> Makefile |
|
58 | 58 | echo "ARCH = $ARCH" >> Makefile |
|
59 | 59 | echo "ARCHFOLDER = "'$(LIBUC)'"/rules/$ARCH" >> Makefile |
|
60 | 60 | echo "TARGET=$TARGET">> Makefile |
|
61 | 61 | echo "LIBUC_INCLUDES=$INCLUDES">> Makefile |
|
62 | 62 | echo "LIBUC_LIBRARIES=$LIBRARIES">> Makefile |
|
63 | 63 | echo "TARGETINSTALLPATH=$TARGETINSTALLPATH">> Makefile |
|
64 | 64 | echo "HEADERSINSTALLPATH=$HEADERSINSTALLPATH">> Makefile |
|
65 | 65 | echo "BSP=$BSP">> Makefile |
|
66 | 66 | echo 'include $(ARCHFOLDER)/rules.mk' >> Makefile |
|
67 | 67 | echo "$CFLAGS" >> Makefile |
|
68 | 68 | echo "$LDFLAGS" >> Makefile |
|
69 | 69 | echo "$ODFLAGS" >> Makefile |
|
70 | 70 | echo '' >> Makefile |
|
71 | 71 | echo 'all:lib' >> Makefile |
|
72 | 72 | echo " @echo Code compiled" >> Makefile |
|
73 | 73 | echo '' >> Makefile |
|
74 | 74 | echo 'libclean:' >> Makefile |
|
75 | 75 | echo ' rm -f $(TARGETINSTALLPATH)/*.a' >> Makefile |
|
76 | 76 | echo ' rm -f $(HEADERSINSTALLPATH)/*.h' >> Makefile |
|
77 | 77 | echo " Makefile writing finished" |
|
78 | 78 | echo "" |
|
79 | 79 | echo "=========================================================================" |
|
80 | 80 | echo "" |
|
81 | 81 | |
|
82 | 82 | else |
|
83 | 83 | echo "Multi targets" |
|
84 | 84 | for ITEMS in $TARGETS |
|
85 | 85 | do |
|
86 | 86 | echo 'PROJECTDIR = `pwd`'> $ITEMS.mk |
|
87 | 87 | echo "LIBUC = $libuc2" >> $ITEMS.mk |
|
88 | 88 | Target $PROJECTFILE $ITEMS |
|
89 | 89 | Arch $PROJECTFILE $ITEMS |
|
90 | 90 | Objdir $PROJECTFILE |
|
91 | 91 | Bindir $PROJECTFILE |
|
92 | 92 | Libs_Inc $PROJECTFILE $ITEMS |
|
93 | 93 | Libs_Link $PROJECTFILE $ITEMS |
|
94 | 94 | HeadersInstallPath $PROJECTFILE $ITEMS |
|
95 | 95 | TargetInstallPath $PROJECTFILE $ITEMS |
|
96 | 96 | getBSP $PROJECTFILE $ITEMS |
|
97 | 97 | ExtractCFLAGS $PROJECTFILE $ITEMS |
|
98 | 98 | ExtractLDFLAGS $PROJECTFILE $ITEMS |
|
99 | 99 | ExtractODFLAGS $PROJECTFILE $ITEMS |
|
100 | 100 | echo "Current BSP is $BSP" |
|
101 | 101 | echo $SRCFILES >> $ITEMS.mk |
|
102 | 102 | TEMP=`getFilesList $PROJECTFILE $ITEMS.HEADERS` |
|
103 | 103 | if [ -z "$TEMP" ] ; then |
|
104 | 104 | getFilesList $PROJECTFILE '*'.HEADERS | sed 's/*\.'// >> $ITEMS.mk |
|
105 | 105 | else |
|
106 | 106 | getFilesList $PROJECTFILE $ITEMS.HEADERS | sed s/$ITEMS'\.'// >> $ITEMS.mk |
|
107 | 107 | fi |
|
108 | 108 | TEMP=`getFilesList $PROJECTFILE $ITEMS.SOURCES` |
|
109 | 109 | if [ -z "$TEMP" ] ; then |
|
110 | 110 | getFilesList $PROJECTFILE '*'.SOURCES | sed 's/*\.'SOURCES/LIBSOURCES/ >> $ITEMS.mk |
|
111 | 111 | else |
|
112 | 112 | getFilesList $PROJECTFILE $ITEMS.SOURCES | sed s/$ITEMS'\.'SOURCES/LIBSOURCES/ >> $ITEMS.mk |
|
113 | 113 | fi |
|
114 | 114 | echo "=========================================================================" |
|
115 | 115 | echo " M A K E F I L E G E N E R A T I O N " |
|
116 | 116 | echo "-------------------------------------------------------------------------" |
|
117 | 117 | echo " Template = library " |
|
118 | 118 | echo " Architecture = $ARCH " |
|
119 | 119 | echo " Output file = $TARGET " |
|
120 | 120 | echo "=========================================================================" |
|
121 | 121 | echo "" |
|
122 | 122 | echo " Start Writing Makefile ..." |
|
123 | 123 | echo "OBJDIR = $OBJDIR" >> $ITEMS.mk |
|
124 | 124 | echo "BINDIR = $BINDIR" >> $ITEMS.mk |
|
125 | 125 | echo 'OBJECTFILES = $(LIBSOURCES:.c=.o)'>> $ITEMS.mk |
|
126 | 126 | echo 'OBJECTFILES := $(addprefix $(OBJDIR)/,$(OBJECTFILES))'>> $ITEMS.mk |
|
127 | 127 | echo "ARCH = $ARCH" >> $ITEMS.mk |
|
128 | 128 | echo "ARCHFOLDER = "'$(LIBUC)'"/rules/$ARCH" >> $ITEMS.mk |
|
129 | 129 | echo "TARGET=$TARGET">> $ITEMS.mk |
|
130 | 130 | echo "LIBUC_INCLUDES=$INCLUDES">> $ITEMS.mk |
|
131 | 131 | echo "LIBUC_LIBRARIES=$LIBRARIES">> $ITEMS.mk |
|
132 | 132 | echo "TARGETINSTALLPATH=$TARGETINSTALLPATH">> $ITEMS.mk |
|
133 | 133 | echo "HEADERSINSTALLPATH=$HEADERSINSTALLPATH">> $ITEMS.mk |
|
134 | 134 | echo "BSP=$BSP">> $ITEMS.mk |
|
135 | 135 | echo 'include $(ARCHFOLDER)/rules.mk' >> $ITEMS.mk |
|
136 | 136 | echo "$CFLAGS" >> $ITEMS.mk |
|
137 | 137 | echo "$LDFLAGS" >> $ITEMS.mk |
|
138 | 138 | echo "$ODFLAGS" >> $ITEMS.mk |
|
139 | 139 | echo '' >> $ITEMS.mk |
|
140 | 140 | echo 'all:lib' >> $ITEMS.mk |
|
141 | 141 | echo " @echo Code compiled" >> $ITEMS.mk |
|
142 | 142 | echo '' >> $ITEMS.mk |
|
143 | 143 | echo 'libclean:' >> $ITEMS.mk |
|
144 | 144 | echo ' rm -f $(TARGETINSTALLPATH)/*.a' >> $ITEMS.mk |
|
145 | if [ -z "$HEADERSINSTALLPATH" ] ; then | |
|
146 | echo "" | |
|
147 | else | |
|
145 | 148 | echo ' rm -f $(HEADERSINSTALLPATH)/*.h' >> $ITEMS.mk |
|
149 | fi | |
|
146 | 150 | echo " Makefile writing finished" |
|
147 | 151 | echo "" |
|
148 | 152 | echo "=========================================================================" |
|
149 | 153 | echo "" |
|
150 | 154 | done |
|
151 | 155 | echo "" >> Makefile |
|
152 | 156 | echo "all:" >> Makefile |
|
153 | 157 | for ITEMS in $TARGETS |
|
154 | 158 | do |
|
155 | 159 | echo " make -f $ITEMS.mk" >> Makefile |
|
156 | 160 | done |
|
157 | 161 | echo "" >> Makefile |
|
158 | 162 | echo "clean:" >> Makefile |
|
159 | 163 | for ITEMS in $TARGETS |
|
160 | 164 | do |
|
161 | 165 | echo " make clean -f $ITEMS.mk" >> Makefile |
|
162 | 166 | done |
|
163 | 167 | echo "" >> Makefile |
|
164 | 168 | echo "distclean:" >> Makefile |
|
165 | 169 | for ITEMS in $TARGETS |
|
166 | 170 | do |
|
167 | 171 | echo " make distclean -f $ITEMS.mk" >> Makefile |
|
168 | 172 | echo " rm -f $ITEMS.mk" >> Makefile |
|
169 | 173 | done |
|
170 | 174 | fi |
|
171 | 175 | |
|
172 | 176 | |
|
173 | 177 | } |
|
174 | 178 |
@@ -1,14 +1,14 | |||
|
1 | 1 | TEMPLATE = lib |
|
2 | 2 | ARCH = stm32f4-arm-none-eabi-gcc |
|
3 | 3 | TARGET = libgpio |
|
4 | 4 | TARGETINSTALLPATH = $(LIBUC_LIBS_DIR_GPIO) |
|
5 |
HEADERSINSTALLPATH = |
|
|
5 | HEADERSINSTALLPATH = | |
|
6 | 6 | |
|
7 | 7 | LIBS += CORE UHANDLE STLIB |
|
8 | 8 | |
|
9 | 9 | SOURCES += gpio.c |
|
10 | 10 | |
|
11 | 11 | |
|
12 | 12 | HEADERS += |
|
13 | 13 | |
|
14 | 14 | INCLUDES += $(LIBUC_INC_DIR_GPIO) |
@@ -1,14 +1,14 | |||
|
1 | 1 | TEMPLATE = lib |
|
2 | 2 | ARCH = stm32f4-arm-none-eabi-gcc |
|
3 | 3 | TARGET = libuart |
|
4 | 4 | TARGETINSTALLPATH = $(LIBUC_LIBS_DIR_UART) |
|
5 |
HEADERSINSTALLPATH = |
|
|
5 | HEADERSINSTALLPATH = | |
|
6 | 6 | |
|
7 | 7 | LIBS += UHANDLE STLIB |
|
8 | 8 | |
|
9 | 9 | SOURCES += uart.c |
|
10 | 10 | |
|
11 | 11 | |
|
12 | 12 | HEADERS += |
|
13 | 13 | INCLUDES += $(LIBUC_INC_DIR_UART) |
|
14 | 14 |
@@ -1,7 +1,7 | |||
|
1 | 1 | TEMPLATE = dir |
|
2 |
SUBDIRS += STLIB CORE UART |
|
|
2 | SUBDIRS += STLIB CORE UART GPIO | |
|
3 | 3 | |
|
4 | 4 | |
|
5 | 5 | |
|
6 | 6 | |
|
7 | 7 |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now