Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
<BRD_APPTWELITE>
This board BEHAVIOR assumes the same wiring as the standard application App_Twelite. It has constant definitions and readout functions for M1-M3 and BPS pins.
The following constants are defined. BRD_APPTWELITE::PIN_DI1
.
Methods are provided to obtain the values of the DIP SW (M1 M2 M3 BPS) pins.
The return value is not HIGH or LOW, but 0
means that the switch is not set (HIGH side) and 1
means that the switch is set (LOW side).
get_DIPSW_BM()
returns the value of M1, M2, M3 and BPS pins in order from bit0.
This value is checked at system startup and is not updated by operating the switch thereafter.
<PAL_MAG>
Board BEHAVIOR for OPEN-CLOSE SENSE PAL OPEN-CLOSE SENSE PAL.
The sensor of the open/close sensor pal is a magnetic sensor, which is the only input for the interrupt of the two signal lines.
PAL_MAG::PIN_NSNSNS_NORTH
is interrupted when the sensor detects an N-pole and PAL_MAG::PIN_NSNSNS_SOUTH
is interrupted when the sensor detects an N-pole.
The following settings should be made before sleep
Check the IO of the waking factor upon waking.
Board behaviors
Board BEHAVIOR contains procedures for handling hardware connected to a TWELITE radio microcontroller.
Definition of constants (e.g., pin numbers)
Initialization of hardware
Handling of sensors, etc.
<PAL_AMB>
Board BEHAVIOR for Environmental Sensor Pal AMBIENT SENSE PAL.
Common Definition plus the sensors on the board can be handled.
Temperature/humidity sensor SHTC3
Illuminance sensor LTR308ALS
SHTC3 sensor object.
LTR308ALS sensor object.
<PAL_MOT>
Board BEHAVIOR for MOTION SENSE PAL MOTION SENSE PAL.
In addition to common definitions, it can handle sensors on the board.
Accelerometer MC3630
MC3630 Sensor object.
<PAL_NOTICE>
Board BEHAVIOR for NOTICE PAL.
In addition to common definition plus the ability to handle sensors on the board.
LED driver PCA9632
Accelerometer MC3630
[PCA9632 device](... /... /sensor_object/pca9632-leddoraiba.md) object. The board definition performs Wire initialization and device initialization. In principle, it is controlled using the PCA9632 operation method described below.
It is not possible to continuously draw a large current from a CR2032 coin cell. In this board definition, the maximum illuminance setting in normal operation is set at a PWM duty ratio of approximately 50%, but even at this setting, overload effects may be apparent. Adjust the combination of LEDs, illumination intensity, and blinking according to the operating requirements.
When using coin cell batteries, periodic, momentary flashing can mitigate the effects of large currents.
For example, a setting that allows the LED to flash for 20 ms every second or so will not only maintain sufficient visual brightness to mitigate the above effects, but will also reduce battery drain. ) {endhint %}
MC3630 sensor object. The board definition includes SPI initialization, MC3630 device initialization, and MC3630 interrupt processing. Various processes are handled by sns_MC3630
.
NOTICE PAL has a FET switch at the rear of the PCA9632 output. The LED will not light unless this switch is turned ON.
Set individual LEDs to off, on, or blinking.
set_leds() changes the lighting status of all LEDs. Parameters are lighting statePAL_NOTICE::LED_OFF
PAL_NOTICE::LED_ON
PAL_NOTICE::LED_BLINK
PAL_NOTICE::LED_NOP
.
Specifies the PWM duty ratio (LED lighting brightness).
set_led_brightness_? _reg()
and set_leds_brightness_reg()
specify the register value directly. 0...255 is specified and the lighting will be the ratio duty/256
.
set_led_brightness_?1000()
and set_leds_brightness1000()
specify a duty ratio of 0..1000, where 0 corresponds to no light and the larger the value, the brighter (longer lighting interval). If boost
is set to false
, the register value is 127 when 1000 is specified. If boost
is set to true
, the register value will be 255.
Since PAL is operated by a coin cell battery, the specified maximum value is set to a duty ratio of approximately 50%.
The final setting is assigned to the register value, so even if 0...1000 steps are specified, the actual control value will be the precision of the register value.
LEDs with PAL_NOTICE::LED_BLINK
will blink with the specified period and lighting duration ratio.
Blinking patterns cannot be specified individually.
Brightness can also be controlled since the LEDs are turned on at the PWM duty ratio specified in the lighting illuminance setting above.
set_blink_cycle_ms()
blinks for a period of time specified by x
.
set_blink_duty1000()sets
xto 0..1000 and blinks for
cycle*x/1000` as the lighting period.
The final setting is assigned to the register value, so even if you specify 0...1000 steps, the actual control value will be the precision of the register value.
Turns on the 4 LEDs for a very short period of time. After lighting, the master switch is turned on (set_led_master_sw_on()
).
PAL common interface.
TWELITE PAL's hardware has common parts, and board BEHAVIOR also defines common interfaces for common hardware.
The following definitions are available
It can be accessed as PAL_AMB::PIN_BTN
.
Each pin is initialized as shown in the code above.
Resets the external watchdog timer at startup, sleep wakeup, and after a certain period of time after startup.
To avoid watchdog timer timeout, TWELITE should be set to wake up within 60 seconds (when using calibrated internal CR timer).
LED (D1) control.
Do not call this method if you do not want to control with board BEHAVIOR.
mode
は以下のパラメータを取ります。tick
は点灯時間[ms]を指定しますが、詳細はmode
の解説を参照してください。
The setting before the return to sleep is maintained after the return to sleep.
Turns on the LED for a specified period of time. Cannot be used at the same time as the set_led()
function.
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
.
The opposite of HIGH(1),LOW(0)
of D1...D4.
This is because the LOW(0)
side of the DIP SW is set, meaning it has a value of 1
.
This value is checked at system startup and is not updated by manipulating the switch thereafter.
<MONOSTICK>
Board BEHAVIOR for MONOSTICK. It includes procedures for controlling the built-in watchdog timer and lighting LEDs.
The following definitions will be available
It can be accessed as MONOSTICK::PIN_LED
.
Each pin is initialized as shown in the code above.
Resets the external watchdog timer at startup, sleep wakeup, and after a certain period of time after startup.
Watchdog timer timeout is 1 second.
MONOSTICK does not normally run applications that sleep, in which case it sets MONOSTICK::PIN_WDT_EN
to HIGH before sleeping.
LED (red, yellow) control.
Do not call this method if you do not want to control with board BEHAVIOR.
The yellow LED (MONOSTICK::PIN_LED_YELLOW
) is the SPIMISO pin (semiconductor pin name DO1). This board BEHAVIOR does not include methods and procedures for lighting by PWM control. If necessary, the following description is made.
Do not call set_led_yellow()
.
Initialize PWM output separately after startup; the SPIMISO pin corresponds to PWM3 in the App_Twelite standard application and can be controlled by the Timer3 class object.
The PWM output is initialized separately after sleep recovery. At that time, the output setting of DO1 is canceled.
Before setting PWM, cancel the output setting of DO1. \1} pinMode(PIN_LED_YELLOW, DISABLE_OUTPUT);
The yellow LED (MONOSTICK::PIN_LED_YELLOW
) cannot be turned on during sleep.
mode
takes the following parameters. The tick
specifies the lighting time [ms], please refer to the description of mode
for details.
The setting before the return to sleep is maintained after the return to sleep.
<CUE>
It can handle accelerometers, magnetic sensors, and LEDs on the board.
Accelerometer
Magnetic sensor
LEDs
The sensor of the open/close sensor pal is a magnetic sensor, which is the only input for the interrupt of the two signal lines.
The PAL_MAG::PIN_SNS_NORTH
is interrupted when the sensor detects an N-pole and the PAL_MAG::PIN_SNS_SOUTH
is interrupted when the sensor detects an N-pole.
The following settings should be made before sleep
Check the IO of the waking factor upon waking.
LED (D1) control.
Do not call this method if you do not want to control with board BEHAVIOR.
The mode
takes the following parameters. tick
specifies the lighting time [ms], see the description of mode
for details.
The setting before the return to sleep is maintained after the return to sleep.
Turns on the LED for a specified period of time. Cannot be used with set_led()
function at the same time.
Resets the external watchdog timer at startup, sleep wakeup, and after a certain period of time after startup.
Wake TWELITE within 60 seconds (when using calibrated internal CR timer) to avoid watchdog timer timeout.
Definition | Meaning |
---|---|
Definition | Meaning |
---|---|
Definition | Meaning |
---|---|
Designation | Meaning |
---|---|
specification | meaning |
---|---|
Board BEHAVIOR for peripherals on .
The member object (sns_MC3630) is defined.
Designation | Meaning |
---|
PAL_NOTICE::LED_OFF
OFF
PAL_NOTICE::LED_ON
On (PWM illuminance control)
PAL_NOTICE::LED_BLINK
Blinking
PAL_NOTICE::LED_NOP
Do not change
PAL_NOTICE::LED_R
LED Red
PAL_NOTICE::LED_G
LED Green
PAL_NOTICE::LED_B
LED Green
PAL_NOTICE::LED_W
LED White
PAL_NOTICE::LED_REG_MAX_PWM
PMW register set value for standard illuminance (1/2 of all lights are standard)
PAL_NOTICE::LED_REG_BOOST_PWM
PWM register set value for boosting
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.
LED_TIMER::BLINK
Blinks the LED. ON/OFF is toggled every time tick
is given. 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.
| Blinks the LED. ON/OFF is toggled every [ms] of time given to |
| When a packet is received, it turns on for the time given to the |
| Turns on for the time given to the |