Files
pico-keys-sdk/src/fs/phy.h
Pol Henarejos 812f075ee4 Add UP button timeout to PHY.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-11-25 12:57:17 +01:00

65 lines
1.8 KiB
C

/*
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _PHY_H_
#define _PHY_H_
#define EF_PHY 0xE020
#define PHY_VIDPID 0x0
#define PHY_LED_GPIO 0x4
#define PHY_LED_BTNESS 0x5
#define PHY_OPTS 0x6
#define PHY_UP_BTN 0x8
#define PHY_OPT_WCID 0x1
#define PHY_OPT_DIMM 0x2
#include <stdint.h>
#include <stdbool.h>
typedef struct phy_data {
union {
struct {
uint16_t vid;
uint16_t pid;
};
uint8_t vidpid[4];
};
uint8_t led_gpio;
uint8_t led_brightness;
uint16_t opts;
uint8_t up_btn;
bool vidpid_present;
bool led_gpio_present;
bool led_brightness_present;
bool up_btn_present;
} phy_data_t;
#define PHY_OPT_MASK (PHY_UP_BTN | PHY_OPT_SECURE_LOCK | PHY_OPT_SECURE_BOOT | PHY_OPT_DIMM | PHY_OPT_WCID)
#define PHY_MAX_SIZE 9
#ifndef ENABLE_EMULATION
extern int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len);
extern int phy_unserialize_data(const uint8_t *data, uint16_t len, phy_data_t *phy);
extern int phy_init();
extern phy_data_t phy_data;
#endif
#endif // _PHY_H_