Refactor PHY to support more flexible and scalable architecture.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2024-11-05 00:25:41 +01:00
parent 802df9e705
commit 0638409ff8
12 changed files with 177 additions and 110 deletions

60
src/fs/phy.h Normal file
View File

@@ -0,0 +1,60 @@
/*
* 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_OPT_WCID 0x1
#define PHY_OPT_DIMM 0x2
#define PHY_OPT_SECURE_BOOT 0x4
#define PHY_OPT_SECURE_LOCK 0x8
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;
bool vidpid_present;
bool led_gpio_present;
bool led_brightness_present;
} phy_data_t;
#define PHY_OPT_MASK (PHY_OPT_SECURE_LOCK | PHY_OPT_SECURE_BOOT | PHY_OPT_DIMM | PHY_OPT_WCID)
#define PHY_MAX_SIZE 8
#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_