Git
Wiki
Site
projects
/
soft
/
lpc82x
/
exanh
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6450d3e
)
Add flushes and instruction barriers so that GCC does what we need with the Tx line...
author
Nathael Pajani
<nathael.pajani@ed3l.fr>
Wed, 24 May 2017 12:44:21 +0000
(14:44 +0200)
committer
Nathael Pajani
<nathael.pajani@ed3l.fr>
Sat, 11 Feb 2023 04:09:54 +0000
(
05:09
+0100)
v04/main.c
patch
|
blob
|
history
diff --git
a/v04/main.c
b/v04/main.c
index
be8d52f
..
ef4dae6
100644
(file)
--- a/
v04/main.c
+++ b/
v04/main.c
@@
-29,6
+29,7
@@
#include "core/pio.h"
#include "core/iap.h"
#include "lib/stdio.h"
#include "core/pio.h"
#include "core/iap.h"
#include "lib/stdio.h"
+#include "lib/utils.h"
#include "drivers/i2c.h"
#include "drivers/adc.h"
#include "drivers/serial.h"
#include "drivers/i2c.h"
#include "drivers/adc.h"
#include "drivers/serial.h"
@@
-47,20
+48,30
@@
#define SELECTED_FREQ FREQ_SEL_36MHz
#define SELECTED_FREQ FREQ_SEL_36MHz
-#define DEBUG 0
-#if (DEBUG == 1)
+#define DEBUG 1
+#if (DEBUG == 1) /* Send only on prog output */
+ #define debug_printf(...) \
+ uprintf(__VA_ARGS__); \
+
+ #define debug(cond, ...) \
+ if (cond) { \
+ uprintf(UART0, __VA_ARGS__ ); \
+ }
+
+#elif (DEBUG == 2) /* Send on comm port */
#define debug_printf(...) \
gpio_clear(tx_en); \
uprintf(__VA_ARGS__); \
#define debug_printf(...) \
gpio_clear(tx_en); \
uprintf(__VA_ARGS__); \
+ serial_flush(UART0); \
gpio_set(tx_en);
#define debug(cond, ...) \
if (cond) { \
gpio_clear(tx_en); \
uprintf(UART0, __VA_ARGS__ ); \
gpio_set(tx_en);
#define debug(cond, ...) \
if (cond) { \
gpio_clear(tx_en); \
uprintf(UART0, __VA_ARGS__ ); \
+ serial_flush(UART0); \
gpio_set(tx_en); \
}
gpio_set(tx_en); \
}
-
#else
#define debug_printf(...) ;
#define debug(...) ;
#else
#define debug_printf(...) ;
#define debug(...) ;
@@
-435,11
+446,18
@@
int main(void)
/* Get hold of Tx line */
if (need_config == 1) {
/* Request a new address from host */
/* Get hold of Tx line */
if (need_config == 1) {
/* Request a new address from host */
+ serial_flush(UART0);
+ /* Do not place any of the following instructions before the flush end */
+ isb();
gpio_clear(tx_en);
gpio_clear(tx_en);
- if (serial_
send_quickbyte(UART0, 'c') == 0
) {
+ if (serial_
write(UART0, "$c", 2) == 2
) {
addr_req = 1;
need_config = 0;
}
addr_req = 1;
need_config = 0;
}
+ /* And wait for fush end before relaesing the line */
+ isb();
+ serial_flush(UART0);
+ isb();
gpio_set(tx_en);
}
gpio_set(tx_en);
}
@@
-481,7
+499,7
@@
int main(void)
if (1) {
char buff[20];
uint16_t* data = (uint16_t*)buff;
if (1) {
char buff[20];
uint16_t* data = (uint16_t*)buff;
-
+ memset(buff, 0, 20);
buff[0] = '#';
buff[1] = address | (got_tsl << 5) | (got_veml << 6) | (got_bme << 7);
data[1] = (uint16_t)htons(raw_humidity);
buff[0] = '#';
buff[1] = address | (got_tsl << 5) | (got_veml << 6) | (got_bme << 7);
data[1] = (uint16_t)htons(raw_humidity);
@@
-492,8
+510,15
@@
int main(void)
data[6] = (uint16_t)htons(comp_temp);
data[7] = (uint16_t)htons(humidity);
data[6] = (uint16_t)htons(comp_temp);
data[7] = (uint16_t)htons(humidity);
+ serial_flush(UART0);
+ /* Do not place any of the following instructions before the flush end */
+ isb();
gpio_clear(tx_en);
serial_write(UART0, buff, 20);
gpio_clear(tx_en);
serial_write(UART0, buff, 20);
+ /* And wait for fush end before relaesing the line */
+ isb();
+ serial_flush(UART0);
+ isb();
gpio_set(tx_en);
}
}
gpio_set(tx_en);
}
}
Techno-Innov
42 impasse de la Combe du Bois
01150 Blyes - France
contact@techno-innov.fr
Design et hébergement du site :
Techno-Innov
Techno-Innov
- SARL Coopérative
539 169 417 RCS Bourg-en-Bresse
Ce site n'utilise pas de cookies, désolé pour les gourmands !