@@ -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 |
@@ -142,7 +142,11 function template-run { | |||||
142 | echo '' >> $ITEMS.mk |
|
142 | echo '' >> $ITEMS.mk | |
143 | echo 'libclean:' >> $ITEMS.mk |
|
143 | echo 'libclean:' >> $ITEMS.mk | |
144 | echo ' rm -f $(TARGETINSTALLPATH)/*.a' >> $ITEMS.mk |
|
144 | echo ' rm -f $(TARGETINSTALLPATH)/*.a' >> $ITEMS.mk | |
|
145 | if [ -z "$HEADERSINSTALLPATH" ] ; then | |||
|
146 | echo "" | |||
|
147 | else | |||
145 | echo ' rm -f $(HEADERSINSTALLPATH)/*.h' >> $ITEMS.mk |
|
148 | echo ' rm -f $(HEADERSINSTALLPATH)/*.h' >> $ITEMS.mk | |
|
149 | fi | |||
146 | echo " Makefile writing finished" |
|
150 | echo " Makefile writing finished" | |
147 | echo "" |
|
151 | echo "" | |
148 | echo "=========================================================================" |
|
152 | echo "=========================================================================" |
@@ -2,7 +2,7 TEMPLATE = lib | |||||
2 | ARCH = stm32f4-arm-none-eabi-gcc |
|
2 | ARCH = stm32f4-arm-none-eabi-gcc | |
3 | TARGET = libgpio |
|
3 | TARGET = libgpio | |
4 | TARGETINSTALLPATH = $(LIBUC_LIBS_DIR_GPIO) |
|
4 | TARGETINSTALLPATH = $(LIBUC_LIBS_DIR_GPIO) | |
5 |
HEADERSINSTALLPATH = |
|
5 | HEADERSINSTALLPATH = | |
6 |
|
6 | |||
7 | LIBS += CORE UHANDLE STLIB |
|
7 | LIBS += CORE UHANDLE STLIB | |
8 |
|
8 |
@@ -2,7 +2,7 TEMPLATE = lib | |||||
2 | ARCH = stm32f4-arm-none-eabi-gcc |
|
2 | ARCH = stm32f4-arm-none-eabi-gcc | |
3 | TARGET = libuart |
|
3 | TARGET = libuart | |
4 | TARGETINSTALLPATH = $(LIBUC_LIBS_DIR_UART) |
|
4 | TARGETINSTALLPATH = $(LIBUC_LIBS_DIR_UART) | |
5 |
HEADERSINSTALLPATH = |
|
5 | HEADERSINSTALLPATH = | |
6 |
|
6 | |||
7 | LIBS += UHANDLE STLIB |
|
7 | LIBS += UHANDLE STLIB | |
8 |
|
8 |
@@ -1,5 +1,5 | |||||
1 | TEMPLATE = dir |
|
1 | TEMPLATE = dir | |
2 |
SUBDIRS += STLIB CORE UART |
|
2 | SUBDIRS += STLIB CORE UART GPIO | |
3 |
|
3 | |||
4 |
|
4 | |||
5 |
|
5 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now