GlobLib
HAL and API libraries for MCUs and hardware.
ucconfig.h
Go to the documentation of this file.
1 #ifndef UCCONFIG_H
2 #define UCCONFIG_H_
3 
51 #include <string11.h>
52 #include <flashWrite.h>
53 #include <fifo8.h>
54 #include <stdio.h>
55 
59 #define UCCONFIG_KEY_LENGTH 4
60 
63 #define UCCONFIG_KEY_1 2
64 
67 #define UCCONFIG_KEY_2 4
68 
71 #define UCCONFIG_KEY_3 6
72 
75 #define UCCONFIG_KEY_4 8
76 
79 #define UCCONFIG_FIFO_SIZE 32
80 
84 #define UCCONFIG_FRAME_END 22
85 
88 #define UCCONFIG_SET_MEMORY_ADDRESS 12
89 
92 #define UCCONFIG_SET_WRITE_FRAME 13
93 
96 #define UCCONFIG_READ_FRAME 14
97 
100 #define UCCONFIG_TERMINATE 15
101 
104 #define UCCONFIG_AT_ADDRESS 16
105 
108 #define UCCONFIG_ACK 17
109 
112 #define UCCONFIG_NACK 18
113 
116 #define UCCONFIG_NULL 19
117 
120 #define UCCONFIG_NOT_USED 20
121 
125 #define UCCONFIG_NEWLINE 10
126 
129 #define UCCONFIG_LENGTH_ZERO 21
130 
133 #define UCCONFIG_TYPE_NONE 11
134 
137 #define UCCONFIG_TYPE_UINT8_T 12
138 
141 #define UCCONFIG_TYPE_INT8_T 13
142 
145 #define UCCONFIG_TYPE_UINT16_T 14
146 
149 #define UCCONFIG_TYPE_INT16_T 15
150 
153 #define UCCONFIG_TYPE_UINT32_T 16
154 
157 #define UCCONFIG_TYPE_INT32_T 17
158 
161 #define UCCONFIG_TYPE_FLOAT 18
162 
165 #define UCCONFIG_TYPE_CHAR 19
166 
169 #define UCCONFIG_ACTIVE_MODE_TIMEOUT 0xFFFF
170 
171 
183 #define UCCONFIG_get(X,Y) _Generic((X), \
184  char*: ucconfig_get_c, \
185  uint8_t*: ucconfig_get_u8, \
186  int8_t*: ucconfig_get_8, \
187  uint16_t*: ucconfig_get_u16, \
188  int16_t*: ucconfig_get_16, \
189  uint32_t*: ucconfig_get_u32, \
190  int32_t*: ucconfig_get_32, \
191  float*: ucconfig_get_float, \
192  default: ucconfig_get_u8 \
193  )(X,Y)
194 
205 void UCCONFIG_setup(
206  uint8_t (*flash_read)(uint16_t address),
207  void (*flash_write)(uint8_t byte,uint16_t adrress),
208  void (*serial_write)(uint8_t byte));
214 void UCCONFIG_listen(uint8_t receivedByte);
219 void UCCONFIG_loop(void);
225 void UCCONFIG_setAddressOffset(uint16_t address);
231 void UCCONFIG_setOnEnter(void (*on_enter)(void));
237 void UCCONFIG_setOnExit(void (*on_exit)(void));
243 void UCCONFIG_setOnFirstWrite(void (*on_first)(void));
252 void ucconfig_get_c(char *data,uint16_t address);
261 void ucconfig_get_u8(uint8_t *data,uint16_t address);
270 void ucconfig_get_8(int8_t *data,uint16_t address);
279 void ucconfig_get_u16(uint16_t *data,uint16_t address);
288 void ucconfig_get_16(int16_t *data,uint16_t address);
297 void ucconfig_get_u32(uint32_t *data,uint16_t address);
306 void ucconfig_get_32(int32_t *data,uint16_t address);
315 void ucconfig_get_float(float *data,uint16_t address);
316 
319 #endif
void ucconfig_get_u32(uint32_t *data, uint16_t address)
Get a uint32 from the given memory address.
Definition: ucconfig.c:141
void UCCONFIG_setAddressOffset(uint16_t address)
Set the memory address offset of the flash memory pointer (optional)
Definition: ucconfig.c:159
void UCCONFIG_loop(void)
Runs config mode if the key has been received.
Definition: ucconfig.c:84
void ucconfig_get_u16(uint16_t *data, uint16_t address)
Get a uint16 from the given memory address.
Definition: ucconfig.c:128
void UCCONFIG_setOnExit(void(*on_exit)(void))
Sets the function which is called when config mode is exited (optional)
Definition: ucconfig.c:101
void ucconfig_get_u8(uint8_t *data, uint16_t address)
Get a uint8 from the given memory address.
Definition: ucconfig.c:116
void ucconfig_get_16(int16_t *data, uint16_t address)
Get a int16 from the given memory address.
Definition: ucconfig.c:135
void UCCONFIG_setOnEnter(void(*on_enter)(void))
Sets the function which is called when config mode is entered (optional)
Definition: ucconfig.c:97
Header file for flashWrite library.
Header file for 8-bit circular FIFO software buffer.
void UCCONFIG_setOnFirstWrite(void(*on_first)(void))
Sets the function which is called when the first byte is written to the UC from PC.
Definition: ucconfig.c:105
Header file for C11 string library.
void ucconfig_get_8(int8_t *data, uint16_t address)
Get a int8 from the given memory address.
Definition: ucconfig.c:122
void ucconfig_get_c(char *data, uint16_t address)
Get a character from the given memory address.
Definition: ucconfig.c:110
void ucconfig_get_32(int32_t *data, uint16_t address)
Get a int32 from the given memory address.
Definition: ucconfig.c:147
void ucconfig_get_float(float *data, uint16_t address)
Get a float from the given memory address.
Definition: ucconfig.c:153
void UCCONFIG_listen(uint8_t receivedByte)
Listens to serial communication and sets module in config mode if correct key is sent.
Definition: ucconfig.c:1007
void UCCONFIG_setup(uint8_t(*flash_read)(uint16_t address), void(*flash_write)(uint8_t byte, uint16_t adrress), void(*serial_write)(uint8_t byte))
Set up the module, this should be called before any other module function will work.