Nol.A SDK Library 26.11.2
For IoT System Software Development
Loading...
Searching...
No Matches
feather-m0/Basic/main.cpp
#include <cox.h>
Timer timerHello;
static void taskHello(void *) {
struct timeval t;
gettimeofday(&t, nullptr);
Serial2.printf("- [%lu.%06lu] Hello World!\n", (uint32_t) t.tv_sec, t.tv_usec);
int32_t vcc = System.getSupplyVoltage();
Serial2.printf("- Supply voltage: %ld mV\n", vcc);
// digitalToggle(D13);
Serial2.printf("- A0: %ld (%ld), VBAT=%ld mV\n",
map(analogRead(A0), 0, 4095, 0, 2230), analogRead(A0), map(analogRead(D9), 0, 4095, 0, 2230 * 2));
}
void setup() {
Serial2.begin(115200);
Serial2.printf("\n*** [Feather-M0] Basic ***\n");
uint32_t rcause = System.getResetReason();
Serial2.printf("- Reset reason:0x%08lx\n", rcause);
Serial2.onReceive([](SerialPort &p) {
while (p.available() > 0) {
char c = p.read();
Serial2.write(c);
}
});
Serial2.listen();
timerHello.onFired(taskHello, NULL);
timerHello.startPeriodic(500);
pinMode(D13, OUTPUT);
digitalWrite(D13, HIGH);
Serial2.printf("- random(): %lu\n", random()); // This value must be changed on every boot.
pinMode(A0, INPUT);
}
시리얼 포트를 제어하기 위한 클래스
Definition SerialPort.hpp:76
virtual int read()
포트 내부 버퍼에 수신된 문자를 하다 꺼냅니다.
virtual int available()
포트 내부 수신버퍼에 수신된 문자의 갯수를 반환합니다.
Timer는 일정 시간 이후에 1회 실행될 작업, 매 일정 시간마다 실행될 작업 등을 위한 기능입니다.
Definition Timer.hpp:61
bool startPeriodic(uint32_t millis, bool interrupt=false)
작업함수를 매 millis 밀리초 주기로 반복하여 실행합니다.
void onFired(void(*func)(void *), void *args=nullptr)
타이머 만료시 실행시킬 작업함수를 지정합니다.
API and definitions.
long map(long x, long in_min, long in_max, long out_min, long out_max)
수를 어떤 범위에서 다른 범위로 매핑시킵니다.
bool digitalWrite(int8_t pin, int value)
pin 를 HIGH 또는 LOW 로 설정합니다.
bool pinMode(int8_t pin, enum ioDirection direction)
pin 을 direction 방향을 갖는 디지털 핀으로 동작하도록 설정합니다.
@ OUTPUT
Definition nola-common.h:383
@ INPUT
Definition nola-common.h:382
SerialPort & Serial2