Functions
System functions (time, random numbers)
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Obtain the system time, [ms].
Obtain the system time, [ms].
The system tick time is updated by TickTimer interrupt.
Wait for time by polling (specified in μsec).
It is not included in MWSDK2020_05. Supported packages will be MWSDK_2020_07_UNOFFICIAL or later.
Wait for time by polling (specified in μsec).
Wait for a given period of time in microsec
.
The time is measured by the TickTimer count. When waiting for a long time, the CPU clock is reduced and polling is performed.
In the setup(), wakeup()
function, TickTimer is not yet running, so it waits for a while in a while loop. In this case, the error with the specified value will be large. This loop counter is adjusted to 32Mhz. If the CPU clock is changed in these functions, the error will be proportional to the clock.
If you specify a short time, such as less than 10 for a parameter, the error may be large.
Waiting for time by polling.
Waiting for time by polling.
The program waits for a given period of time in ms
.
The time is measured by the TickTimer count. When waiting for a long period of time, the CPU clock is decreased and polling is performed.
Every 5ms after calling delay()
, TWELITE microcontroller performs internal watchdog processing.
For example, if you execute while(1) delay(1);
, the watchdog processing is not performed because 5ms does not elapse inside delay()
, and the reset is executed after a certain time.
In the setup(), wakeup()
function, the TickTimer is not yet running, so it waits for a time by a while loop. In this case, the error with the specified value will be large. This loop counter is adjusted to 32Mhz. If the CPU clock is changed in these functions, the error will be proportional to the clock.
If you specify a short time, such as 1 or 2 as a parameter, the error may be large.
Generates an random number.
Generates an random number.
The first line returns the value of 0.. (maxval-1)
value is returned. Note that the value of maxval is not the maximum value.
The second line returns the value of minval..maxval-1
.
API for DIO (General-purpose digital IO)
The following functions are used for general-purpose digital IO (DIO) operations.
pinMode()
digitalWrite()
digitalRead()
attachIntDio()
detachIntDio()
The following enumeration values are handled with the type name E_PIN_MODE
.
The following enumeration values are handled with the type name E_PIN_MODE
.
The following enumeration values are handled with the type name E_PIN_STATE
.
The following enumeration values are handled with the type name E_PIN_INT_MODE
.
Definition | Name |
---|---|
Definition | Pull-up | Name |
---|---|---|
Definition | Name |
---|---|
Definition | Value | Name |
---|---|---|
Definition | Name |
---|---|
const uint8_t PIN_DIGITAL::DIO0 .. 19
DIO pins 0 to 19
const uint8_t PIN_DIGITAL::DO0 .. 1
DO pin 0,1
PIN_MODE::INPUT
None
Input
PIN_MODE::OUTPUT
None
Output
PIN_MODE::INPUT_PULLUP
Yes
Input
PIN_MODE::OUTPUT_INIT_HIGH
None
Output(init HIGH)
PIN_MODE::OUTPUT_INIT_LOW
None
Output(init LOW)
PIN_MODE::WAKE_FALLING
None
Input, raised pin, falling
PIN_MODE::WAKE_RISING
None
Input, rising pin, rising
PIN_MODE::WAKE_FALLING_PULLUP
Yes
Input, raised pin, falling
PIN_MODE::WAKE_RISING_PULLUP
Yes
Input, rising pin, rising
PIN_MODE::DISABLE_OUTPUT
Yes
return to the input state
PIN_MODE::OUTPUT
Contribute
PIN_MODE::OUTPUT_INIT_HIGH
Output (initial state HIGH)
PIN_MODE::OUTPUT_INIT_LOW
Output (initial state LOW)
PIN_MODE::DISABLE_OUTPUT
Stop setting output
PIN_STATE::HIGH
1
HIGH(=Vcc) level
PIN_STATE::LOW
0
LOW(=GND) level
PIN_INT_MODE::FALLING
falling edge
PIN_INT_MODE::RISING
rising edge
Reads the value of the port of the input configuration.
Reads the value of the port of the input configuration.
Get the input value of a pin that has been previously set as an input, either LOW
or HIGH
.
No conversion operator from type E_PIN_STATE
to type int
is defined, so direct assignment to a numeric type is not possible.
to enable DIO interrupt.
Enables DIO interrupts.
For a preconfigured pin, the first parameter is the pin number for which you want to enable interrupts, the second is the interrupt direction (rising, falling.
Interrupt handlers and event handlers are written in Application BEHAVIOR.
Set up an interrupt to be generated when the DIO5 pin changes from HIGH to LOW.
Basic definition of the application behavior myAppClass
. Details are omitted.
Description of the interrupt handler of the application behavior myAppClass
, which inverts the output setting of DIO12 when an interrupt of DIO5 is generated and displays *
on the serial port Serial
for events occurring after the interrupt handler is finished.
Change the setting of the digital output pins.
Change the setting of the digital output pins.
The first parameter specifies the pin number to be set, and the second parameter specifies either HIGH
or LOW
.
The input is of type E_PIN_STATE
. The conversion operator from E_PIN_STATE
to int
type is not defined, so direct numeric input is not allowed.
to unregister the interrupt handler.
Unregisters the interrupt handler.
Reads the values of all ports in the input settings at once.
Included in mwx library 0.1.4 or later
Reads the values of all ports in the input settings at once.
The values are stored in the order of DIO0 ... DIO19 from the LSB side. DIO19 are stored in this order.
The pins on the HIGH side are set to 1 and the pins on the LOW side are set to 0.
Sets 1 at the specified bit position.
Sets 1 at the specified bit position.
Parameters can be specified as a variable number of arguments, each parameter specifying a 0..31 integer that specifies a bit position. For example, specifying pack_bits(1,3,6)
returns ((1UL<<1)|(1UL<<3)|(1UL<<6))
.
constexpr
will expand constants at compile time if computation by constants is possible.
There are situations where values are referenced and set in various bitmaps, such as the status of IO ports (DI, DO), to simplify the description.
Generating bitmaps with specified order.
Obtains the value of a specified bit position from an integer and creates a bitmap of the specified order.
The value corresponding to the bit position 0..31 specified by the subsequent variable number parameter is extracted from the value specified in the parameter bm. The extracted values are arranged in parameter order and returned as a bitmap.
The bitmap is ordered with the first parameter as the upper bit and the last parameter as bit 0.
In the example, taking out bits 4,2,1,0 of b1 yields (1,0,1,0). This is calculated as 0x10 as b1010.
There are situations where values are referenced and set in various bitmaps, such as the status of IO ports (DI, DO), in order to simplify the description.