For the complete documentation index, see llms.txt. This page is also available as Markdown.

PAL

PAL common interface.

TWELITE PAL's hardware has common parts, and board BEHAVIOR also defines common interfaces for common hardware.

constants

The following definitions are available

static const uint8_t PIN_BTN = 12; // button (as SET)
static const uint8_t PIN_LED = 5;  // LED
static const uint8_t PIN_WDT = 13; // WDT (shall tick every 60sec)

static const uint8_t PIN_D1 = 1; // DIP SW1
static const uint8_t PIN_D2 = 2; // DIP SW2
static const uint8_t PIN_D3 = 3; // DIP SW3
static const uint8_t PIN_D4 = 4; // DIP SW4

static const uint8_t PIN_SNS_EN = 16;
static const uint8_t PIN_SNS_INT = 17;

It can be accessed as PAL_AMB::PIN_BTN.

Hardware initialization

pinMode(PIN_BTN, INPUT_PULLUP);
pinMode(PIN_LED, OUTPUT_INIT_HIGH);
pinMode(PIN_WDT, OUTPUT_INIT_HIGH);

pinMode(PIN_D1, INPUT_PULLUP);
pinMode(PIN_D2, INPUT_PULLUP);
pinMode(PIN_D3, INPUT_PULLUP);
pinMode(PIN_D4, INPUT_PULLUP);

Each pin is initialized as shown in the code above.

Watchdog Timer

Resets the external watchdog timer at startup, sleep wakeup, and after a certain period of time after startup.

Methods

set_led()

LED (D1) control.

modeは以下のパラメータを取ります。tickは点灯時間[ms]を指定しますが、詳細はmodeの解説を参照してください。

Designation
Meaning

LED_TIMER::BLINK

Blinks the LED. ON/OFF is toggled every [ms] of time given to tick. After returning from sleep, it resets the count and starts from the lit state.

LED_TIMER::ON_RX

When a packet is received, it turns on for the time given to the tick, LED_TIMER::ON_RX.

LED_TIMER::ON_TX_COMP

Turns on for the time given to the tick when the transmission is completed.

The setting before the return to sleep is maintained after the return to sleep.

led_one_shot()

Turns on the LED for a specified period of time. Cannot be used at the same time as the set_led() function.

get_D1() .. D4(), get_DIPSW_BM()

get_D1() ... get_D4() returns 0 when DIP SW is HIGH (switch is up) and 1 when it is LOW (switch is down).

get_DIPSW_BM() returns the DIP SW setting as 0..15. Returns the sum of SW1==LOW as 1, SW2 == LOW as 2, SW3 == LOW as 4 and SW4 == LOW as 8.

最終更新