Constants
The following constants are defined:
const uint8_t PIN_LED = mwx::PIN_DIGITAL::DIO16; // LED
const uint8_t PIN_WDT = mwx::PIN_DIGITAL::DIO9; // WDT (shall tick < 1sec)
const uint8_t PIN_WDT_EN = mwx::PIN_DIGITAL::DIO11; // WDT (LO as WDT enabled)
const uint8_t PIN_LED_YELLOW = mwx::PIN_DIGITAL::DO1; // YELLOW LED
Accessible via MONOSTICK::PIN_LED
.
Hardware Initialization
pinMode(PIN_LED, OUTPUT_INIT_HIGH);
pinMode(PIN_WDT, OUTPUT_INIT_LOW);
pinMode(PIN_WDT_EN, OUTPUT_INIT_LOW);
pinMode(PIN_LED_YELLOW, OUTPUT);
Pins are initialized as shown in the code above.
Watchdog Timer
The external watchdog timer is reset at startup, after waking from sleep, and after a set duration.
The watchdog timeout is one second.
Although MONOSTICK typically runs non-sleeping applications, if using sleep, set MONOSTICK::PIN_WDT_EN
to HIGH before sleeping.
Methods
set_led()
void set_led_red(uint8_t mode, uint16_t tick)
void set_led_yellow(uint8_t mode, uint16_t tick)
Controls the red and yellow LEDs.
The yellow LED (MONOSTICK::PIN_LED_YELLOW
) is the SPIMISO pin (semiconductor pin name DO1). This board behavior does not include methods or procedures for PWM control. Implement the following steps if needed:
- Avoid calling
set_led_yellow()
. - Initialize PWM output separately after startup. The SPIMISO pin corresponds to PWM3 in App_Twelite and can be controlled by the Timer3 class object.
- Reinitialize PWM output after waking from sleep. At that time, disable output settings for DO1.
- Disable DO1 output before configuring PWM:
pinMode(PIN_LED_YELLOW, DISABLE_OUTPUT);
MONOSTICK::PIN_LED_YELLOW
) cannot be lit during sleep.mode
accepts the following parameters. tick
specifies the lighting duration in milliseconds [ms]; see the descriptions for each mode below.
Parameter | Meaning |
---|---|
LED_TIMER::BLINK | The LED blinks. ON/OFF toggles every tick milliseconds. After waking from sleep, the count resets and starts in the ON state. |
LED_TIMER::ON_RX | Lights the LED for tick milliseconds upon packet reception. |
LED_TIMER::ON_TX_COMP | Lights the LED for tick milliseconds upon transmission completion. |