Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 13 additions & 22 deletions firmware/chimera/proto/DAM.proto
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
syntax = "proto3";

package DAM;
package dam;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capitalize this please -Amir

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm delete this file


enum GpioNetName {
GPIO_NET_NAME_UNSPECIFIED = 0;
TELEM_PWR_EN = 1;
BUZZER_PWR_EN = 2;
TSIM_RED_EN = 3;
NTSIM_GRN_EN = 4;
R_SHDN_SENSE = 5;
L_SHDN_SENSE = 6;
LED = 7;
BOOT = 8;
SD_PRESENT = 9;
N_RTC_INT1 = 10;
_900M = 11;
SD_FAIL = 12;
GPIO_NTP = 1;
GPIO_BUZZER_PWR_EN = 2;
GPIO_TSIM_RED_EN = 3;
GPIO_NTSIM_GRN_EN = 4;
GPIO_R_SHDN_SENSE = 5;
GPIO_L_SHDN_SENSE = 6;
GPIO_LED = 7;
GPIO_BOOT = 8;
GPIO_SD_PRESENT = 9;
GPIO_900M = 10;
GPIO_SD_FAIL = 11;
GPIO_D_P_PULLUP = 12;
}

enum AdcNetName {
ADC_NET_NAME_UNSPECIFIED = 0;
}

enum I2cNetName {
I2C_NET_NAME_UNSPECIFIED = 0;
RTC_I2C= 1;
}
13 changes: 4 additions & 9 deletions firmware/chimera_v2/proto/hexray_proto/dam.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package dam;

enum GpioNetName {
GPIO_NET_NAME_UNSPECIFIED = 0;
GPIO_TELEM_PWR_EN = 1;
GPIO_NTP = 1;
GPIO_BUZZER_PWR_EN = 2;
GPIO_TSIM_RED_EN = 3;
GPIO_NTSIM_GRN_EN = 4;
Expand All @@ -13,12 +13,7 @@ enum GpioNetName {
GPIO_LED = 7;
GPIO_BOOT = 8;
GPIO_SD_PRESENT = 9;
GPIO_N_RTC_INT1 = 10;
GPIO_900M = 11;
GPIO_SD_FAIL = 12;
}

enum I2cNetName {
I2C_NET_NAME_UNSPECIFIED = 0;
I2C_RTC = 1;
GPIO_900M = 10;
GPIO_SD_FAIL = 11;
GPIO_D_P_PULLUP = 12;
}
18 changes: 17 additions & 1 deletion firmware/hexray/DAM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,29 @@ if ("${TARGET}" STREQUAL "binary")
"stm32h5xx_hal_exti.c"
"stm32h5xx_hal_tim.c"
"stm32h5xx_hal_tim_ex.c"
"stm32h5xx_hal_uart.c"
"stm32h5xx_hal_uart_ex.c"
"stm32h5xx_hal_rtc.c"
"stm32h5xx_hal_gpio.c"
"stm32h5xx_hal_fdcan.c"
"stm32h5xx_hal_pcd.c"
"stm32h5xx_hal_sd.c"
"stm32h5xx_hal_crc.c"
"stm32h5xx_ll_sdmmc.c"
"stm32h5xx_ll_usb.c"
"stm32h5xx_hal_pcd_ex.c"
"stm32h5xx_hal_crc_ex.c"
"stm32h5xx_hal_rtc_ex.c"
"stm32h5xx_hal_iwdg.c"
"stm32h5xx_hal_dma.c"
)
set(CUBEMX_INCLUDE_DIRS_ ${CUBEMX_INCLUDE_DIRS} ${SYSTEM_INCLUDE_DIRS})
stm32h562xx_cube_library(
"hexray_DAM_stm32"
"${STM32_HAL_SRCS}"
"${CMAKE_CURRENT_SOURCE_DIR}/src/cubemx/DAM.ioc"
"${CUBEMX_SRCS}"
"${CUBEMX_INCLUDE_DIRS}"
"${CUBEMX_INCLUDE_DIRS_}"
FALSE
"${ARM_CORE}"
)
Expand Down
58 changes: 54 additions & 4 deletions firmware/hexray/DAM/src/chimera.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,65 @@
#include "chimera_v2.hpp"
#include "tasks.h"
#include "hw_gpios.hpp"
#include "shared.pb.h"
#include <dam.pb.h>

#include <optional>
#include <functional>

class DAMChimeraConfig : public chimera_v2::config
{
public:
~DAMChimeraConfig() override = default;
std::optional<std::reference_wrapper<const hw::Gpio>> id_to_gpio(const _GpioNetName *gnn) const override;

std::optional<std::reference_wrapper<const hw::Gpio>> id_to_gpio(const _GpioNetName *gnn) const override
{
if (gnn->which_name != gpio_net_name_tag)
{
LOG_ERROR("Chimera: Expected GPIO net name with tag %d, got %d", gpio_net_name_tag, gnn->which_name);
return std::nullopt;
}

switch (gnn->name.dam_net_name)
{
case dam_GpioNetName_GPIO_NTP:
return std::cref(ntp_pin);
case dam_GpioNetName_GPIO_BUZZER_PWR_EN:
return std::cref(buzzer_pwr_en_pin);
case dam_GpioNetName_GPIO_TSIM_RED_EN:
return std::cref(tsim_red_en_pin);
case dam_GpioNetName_GPIO_NTSIM_GRN_EN:
return std::cref(ntsim_green_en_pin);
case dam_GpioNetName_GPIO_R_SHDN_SENSE:
return std::cref(r_shdn_sense_pin);
case dam_GpioNetName_GPIO_L_SHDN_SENSE:
return std::cref(l_shdn_sense_pin);
case dam_GpioNetName_GPIO_LED:
return std::cref(led_pin);
case dam_GpioNetName_GPIO_BOOT:
return std::cref(boot_pin);
case dam_GpioNetName_GPIO_SD_PRESENT:
return std::cref(sd_present);
case dam_GpioNetName_GPIO_900M:
return std::cref(_900m_pin);
case dam_GpioNetName_GPIO_SD_FAIL:
return std::cref(sd_fail_pin);
case dam_GpioNetName_GPIO_D_P_PULLUP:
return std::cref(d_p_pullup_pin);
default:
case dam_GpioNetName_GPIO_NET_NAME_UNSPECIFIED:
LOG_INFO("Chimera: Unknown GPIO net name");
return std::nullopt;
}
}

public:
DAMChimeraConfig() { gpio_net_name_tag = GpioNetName_dam_net_name_tag; }

} dam_config;

void tasks_preInit() {}
void tasks_init()

[[noreturn]] void tasks_init() // sus, maybe put in tasks_run100Hz()
{
chimera_v2::task(dam_config);
}
}
Loading
Loading