forked from EmbeddedTeam/app_photomagnetic
Configure IR enable pin at initialization
This commit is contained in:
parent
68bc52572a
commit
3b0c0c321f
11
src/temp.cpp
11
src/temp.cpp
@ -1,9 +1,9 @@
|
|||||||
#include <com.hpp>
|
#include <com.hpp>
|
||||||
#include <etl/utility.h>
|
#include <etl/utility.h>
|
||||||
#include <infrared.hpp>
|
#include <infrared.hpp>
|
||||||
|
#include <zephyr/drivers/gpio.h>
|
||||||
#include <zephyr/init.h>
|
#include <zephyr/init.h>
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
|
|
||||||
/* 1 = enable verbose diagnostics (per-second channel dump). */
|
/* 1 = enable verbose diagnostics (per-second channel dump). */
|
||||||
#ifndef APP_DEBUG_PRINT
|
#ifndef APP_DEBUG_PRINT
|
||||||
#define APP_DEBUG_PRINT 0
|
#define APP_DEBUG_PRINT 0
|
||||||
@ -48,7 +48,7 @@ static void OnSendTick(struct k_work *work) {
|
|||||||
Com::SendTemp(r.value().second);
|
Com::SendTemp(r.value().second);
|
||||||
}
|
}
|
||||||
#if APP_DEBUG_PRINT
|
#if APP_DEBUG_PRINT
|
||||||
static uint32_t s_send_tick; /* diag: send counter, ~1s cadence */
|
static uint32_t s_send_tick; /* diag: send counter, ~1s cadence */
|
||||||
if (++s_send_tick % 50 == 0) { /* every ~1 s */
|
if (++s_send_tick % 50 == 0) { /* every ~1 s */
|
||||||
const auto all = Infrared::GetAllSensorValues();
|
const auto all = Infrared::GetAllSensorValues();
|
||||||
printk("[%s]diag tick=%u mask=0x%02X val:", MODULE, (unsigned)s_send_tick,
|
printk("[%s]diag tick=%u mask=0x%02X val:", MODULE, (unsigned)s_send_tick,
|
||||||
@ -63,7 +63,14 @@ static void OnSendTick(struct k_work *work) {
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
#define ZEPHYR_USER_NODE DT_PATH(zephyr_user)
|
||||||
|
auto InitEnblePins() {
|
||||||
|
const gpio_dt_spec en_pin = GPIO_DT_SPEC_GET(ZEPHYR_USER_NODE, en_ir_gpios);
|
||||||
|
gpio_pin_configure_dt(&en_pin, GPIO_OUTPUT_ACTIVE);
|
||||||
|
}
|
||||||
|
|
||||||
static auto Init() -> int {
|
static auto Init() -> int {
|
||||||
|
InitEnblePins();
|
||||||
printk("[%s]temp init\n", MODULE);
|
printk("[%s]temp init\n", MODULE);
|
||||||
if (auto r = Infrared::Init(); r.code_id() != zpp::error_code::k_ok) {
|
if (auto r = Infrared::Init(); r.code_id() != zpp::error_code::k_ok) {
|
||||||
printk("[%s] Infrared::Init failed: %d\n", MODULE,
|
printk("[%s] Infrared::Init failed: %d\n", MODULE,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user