mirror of
https://codeberg.org/SiB64/turbo_weather.git
synced 2026-05-01 15:14:22 +02:00
Compare commits
No commits in common. "f692d97cf033b195c6c8cd62224dc7145caa7258" and "763ab24e9e94cd14e4570757e332896d334a3be1" have entirely different histories.
f692d97cf0
...
763ab24e9e
3 changed files with 14 additions and 36 deletions
20
src/bate.c
20
src/bate.c
|
|
@ -410,11 +410,7 @@ int main()
|
|||
sleep_enable();
|
||||
sei();
|
||||
|
||||
uint8_t reset_source = RSTCTRL.RSTFR;
|
||||
RSTCTRL.RSTFR = reset_source;
|
||||
send_str("\nV Turbo Weather V0.04\nR ");
|
||||
send_hex_byte(reset_source);
|
||||
send_char('\n');
|
||||
send_str("\nV Turbo Weather V0.03\n");
|
||||
|
||||
uint8_t test_calib = config.calib_test;
|
||||
if (test_calib > N_TESTDATA)
|
||||
|
|
@ -471,15 +467,11 @@ int main()
|
|||
}
|
||||
}
|
||||
if (!(trigger & config.triggers)) {
|
||||
if (config.power & (POWER_DOWN|POWER_STDBY)) {
|
||||
mclk(0);
|
||||
if (config.power & POWER_DOWN) {
|
||||
mclk(0);
|
||||
if (config.power & POWER_DOWN_CLI)
|
||||
cli();
|
||||
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
|
||||
}
|
||||
else
|
||||
set_sleep_mode(SLEEP_MODE_STANDBY);
|
||||
sleep_enable();
|
||||
sleep_cpu();
|
||||
set_sleep_mode(SLEEP_MODE_IDLE);
|
||||
|
|
@ -488,12 +480,12 @@ int main()
|
|||
}
|
||||
|
||||
rfen(1);
|
||||
if (config.power & POWER_LED)
|
||||
led(1);
|
||||
|
||||
if (!mclk_status())
|
||||
mclk_delay = config.mclk_delay;
|
||||
if (!mclk_status()) {
|
||||
mclk(1);
|
||||
mclk_delay = config.mclk_delay;
|
||||
}
|
||||
|
||||
if (!tick)
|
||||
continue;
|
||||
|
|
@ -511,10 +503,10 @@ int main()
|
|||
if (config.send & SEND_ADC)
|
||||
start_adc();
|
||||
|
||||
if (config.send & SEND_CLOCK) {
|
||||
cli();
|
||||
uint32_t time = clock;
|
||||
sei();
|
||||
if (config.send & SEND_CLOCK) {
|
||||
send_str("T 0x");
|
||||
send_hex_long(time);
|
||||
send_char('\n');
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@ enum power_flags {
|
|||
POWER_DOWN = 0x01,
|
||||
POWER_DOWN_CLI = 0x02,
|
||||
STOP_MCLK = 0x04,
|
||||
POWER_LED = 0x08,
|
||||
POWER_STDBY = 0x10,
|
||||
};
|
||||
enum send_flags {
|
||||
SEND_CONFIG = 0x01,
|
||||
|
|
|
|||
16
src/uart.c
16
src/uart.c
|
|
@ -56,7 +56,6 @@ uint8_t uart_tick()
|
|||
uint8_t uart_tx[128];
|
||||
volatile uint8_t uart_tx_w;
|
||||
volatile uint8_t uart_tx_r;
|
||||
volatile uint8_t uart_tx_b;
|
||||
static const uint8_t uart_tx_m = sizeof(uart_tx) - 1;
|
||||
|
||||
static inline void tx()
|
||||
|
|
@ -66,8 +65,6 @@ static inline void tx()
|
|||
while (r != uart_tx_w) {
|
||||
if (!(USART0.STATUS & USART_DREIF_bm)) {
|
||||
USART0.CTRLA |= USART_DREIE_bm;
|
||||
USART0.STATUS = USART_TXCIF_bm;
|
||||
uart_tx_b = USART_TXCIF_bm;
|
||||
uart_tx_r = r;
|
||||
return;
|
||||
}
|
||||
|
|
@ -87,20 +84,11 @@ ISR(USART0_DRE_vect)
|
|||
__attribute__ ((noinline, noclone))
|
||||
uint8_t uart_busy()
|
||||
{
|
||||
// How to test if we can power down?
|
||||
// `uart_tx_b` is set to `TXC` when a char is loaded for transmission
|
||||
// and the TXCIF is cleared.
|
||||
// When `uart_tx_b` is zero, we are good,
|
||||
// else when `TXCIF` is set we are also good.
|
||||
// When `uart_tx_b` is set but the `TXCIF` not yet, we are busy,
|
||||
//returning TXC.
|
||||
cli();
|
||||
tx();
|
||||
uint8_t b = uart_tx_b;
|
||||
if (!b || USART0.STATUS & b)
|
||||
b = uart_tx_b = 0;
|
||||
uint8_t r = uart_tx_w - uart_tx_r;
|
||||
sei();
|
||||
return b;
|
||||
return r;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline, noclone))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue