Skip to content

Commit

Permalink
Add REV F to hardware revision checks in codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
codecubepi committed Mar 27, 2024
1 parent 2c26c87 commit 2c70a07
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 35 deletions.
13 changes: 8 additions & 5 deletions sdk/app_cpu1/common/drv/bsp.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include "drv/hardware_targets.h"
#include "usr/user_config.h"

#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_D) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E)
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_D) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) \
|| (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
// Ensure a valid hardware target is specified
// NOTE: this firmware only supports REV D hardware onward
#else
#error "ERROR: Hardware target not specified correctly"
#error "ERROR: Hardware target not specified correctly in user_config.h"
// If you have this error, please define USER_CONFIG_HARDWARE_TARGET in your usr/user_config.h file!
#endif

Expand Down Expand Up @@ -54,6 +55,10 @@ void bsp_init(void)
printf("Hardware Target: REV E\n");
break;

case AMDC_REV_F:
printf("Hardware Target: REV F\n");
break;

default:
printf("ERROR: Unknown AMDC hardware revision\n");
while (1) {
Expand All @@ -79,9 +84,7 @@ void bsp_init(void)

#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_D)
gpio_mux_init();
#endif

#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E)
#elif (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
gp3io_mux_init();
#endif

Expand Down
2 changes: 1 addition & 1 deletion sdk/app_cpu1/common/drv/eddy_current_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void eddy_current_sensor_init(void)
EDDY_CURRENT_SENSOR_DEFAULT_SCLK_FREQ_KHZ,
EDDY_CURRENT_SENSOR_DEFAULT_PROP_DELAY_NS);

#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
eddy_current_sensor_trigger_on_pwm_both(EDDY_CURRENT_SENSOR_2_BASE_ADDR);
eddy_current_sensor_trigger_on_pwm_both(EDDY_CURRENT_SENSOR_3_BASE_ADDR);
eddy_current_sensor_trigger_on_pwm_both(EDDY_CURRENT_SENSOR_4_BASE_ADDR);
Expand Down
2 changes: 1 addition & 1 deletion sdk/app_cpu1/common/drv/eddy_current_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define EDDY_CURRENT_SENSOR_1_BASE_ADDR (XPAR_AMDC_EDDY_CURRENT_SE_0_S00_AXI_BASEADDR)
#endif

#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
#define EDDY_CURRENT_SENSOR_MAX_IP_CORES (XPAR_AMDC_EDDY_CURRENT_SENSOR_NUM_INSTANCES)
#define EDDY_CURRENT_SENSOR_1_BASE_ADDR (XPAR_HIER_GPIO_0_AMDC_EDDY_CURRENT_SE_0_S00_AXI_BASEADDR)
#define EDDY_CURRENT_SENSOR_2_BASE_ADDR (XPAR_HIER_GPIO_1_AMDC_EDDY_CURRENT_SE_0_S00_AXI_BASEADDR)
Expand Down
2 changes: 1 addition & 1 deletion sdk/app_cpu1/common/drv/fpga_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define TMR_DEVICE_ID XPAR_CONTROL_TIMER_1_DEVICE_ID
#endif

#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
#define TMR_DEVICE_ID XPAR_HIER_TIMERS_CONTROL_TIMER_1_DEVICE_ID
#endif

Expand Down
2 changes: 1 addition & 1 deletion sdk/app_cpu1/common/drv/gp3io_mux.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "usr/user_config.h"
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)

#include "drv/gp3io_mux.h"
#include "xil_io.h"
Expand Down
2 changes: 1 addition & 1 deletion sdk/app_cpu1/common/drv/gp3io_mux.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "usr/user_config.h"
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)

#ifndef GP3IO_MUX_H
#define GP3IO_MUX_H
Expand Down
8 changes: 4 additions & 4 deletions sdk/app_cpu1/common/drv/gpio_direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void gpio_direct_init()
gpio_direct_write(GPIO_DIRECT_PORT1, GPIO_DIRECT_PIN2, GPIO_DIRECT_LOW);
gpio_direct_write(GPIO_DIRECT_PORT2, GPIO_DIRECT_PIN1, GPIO_DIRECT_LOW);
gpio_direct_write(GPIO_DIRECT_PORT2, GPIO_DIRECT_PIN2, GPIO_DIRECT_LOW);
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
gpio_direct_write(GPIO_DIRECT_PORT1, GPIO_DIRECT_PIN3, GPIO_DIRECT_LOW);
gpio_direct_write(GPIO_DIRECT_PORT2, GPIO_DIRECT_PIN3, GPIO_DIRECT_LOW);
gpio_direct_write(GPIO_DIRECT_PORT3, GPIO_DIRECT_PIN1, GPIO_DIRECT_LOW);
Expand All @@ -66,7 +66,7 @@ gpio_direct_level_t gpio_direct_read(gpio_direct_port_t port, gpio_direct_pin_t
case GPIO_DIRECT_PORT2:
base_addr = GPIO2_DIRECT_BASE_ADDR;
break;
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
case GPIO_DIRECT_PORT3:
base_addr = GPIO3_DIRECT_BASE_ADDR;
break;
Expand Down Expand Up @@ -96,7 +96,7 @@ void gpio_direct_write(gpio_direct_port_t port, gpio_direct_pin_t pin, gpio_dire
case GPIO_DIRECT_PORT2:
base_addr = GPIO2_DIRECT_BASE_ADDR;
break;
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
case GPIO_DIRECT_PORT3:
base_addr = GPIO3_DIRECT_BASE_ADDR;
break;
Expand Down Expand Up @@ -131,7 +131,7 @@ void gpio_direct_toggle(gpio_direct_port_t port, gpio_direct_pin_t pin)
case GPIO_DIRECT_PORT2:
base_addr = GPIO2_DIRECT_BASE_ADDR;
break;
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
case GPIO_DIRECT_PORT3:
base_addr = GPIO3_DIRECT_BASE_ADDR;
break;
Expand Down
6 changes: 3 additions & 3 deletions sdk/app_cpu1/common/drv/gpio_direct.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#endif // ifdef HARDWARE_TARGET REV_D

#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)

#define GPIO1_DIRECT_BASE_ADDR (XPAR_HIER_GPIO_0_AMDC_GPIO_DIRECT_0_S00_AXI_BASEADDR)
#define GPIO2_DIRECT_BASE_ADDR (XPAR_HIER_GPIO_1_AMDC_GPIO_DIRECT_0_S00_AXI_BASEADDR)
Expand All @@ -26,7 +26,7 @@
typedef enum {
GPIO_DIRECT_PORT1 = 0,
GPIO_DIRECT_PORT2 = 1,
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
GPIO_DIRECT_PORT3 = 2,
GPIO_DIRECT_PORT4 = 3
#endif
Expand All @@ -35,7 +35,7 @@ typedef enum {
typedef enum {
GPIO_DIRECT_PIN1 = 0,
GPIO_DIRECT_PIN2 = 1,
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
GPIO_DIRECT_PIN3 = 2
#endif
} gpio_direct_pin_t;
Expand Down
1 change: 1 addition & 0 deletions sdk/app_cpu1/common/drv/hardware_targets.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

#define AMDC_REV_D (4)
#define AMDC_REV_E (5)
#define AMDC_REV_F (6)

#endif // HARDWARE_TARGETS_H
2 changes: 1 addition & 1 deletion sdk/app_cpu1/common/drv/motherboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void motherboard_init(void)
#endif

motherboard_set_adc_sampling(MOTHERBOARD_1_BASE_ADDR, auto_tx);
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
motherboard_set_adc_sampling(MOTHERBOARD_2_BASE_ADDR, auto_tx);
motherboard_set_adc_sampling(MOTHERBOARD_3_BASE_ADDR, auto_tx);
motherboard_set_adc_sampling(MOTHERBOARD_4_BASE_ADDR, auto_tx);
Expand Down
4 changes: 2 additions & 2 deletions sdk/app_cpu1/common/drv/motherboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define MOTHERBOARD_1_BASE_ADDR (XPAR_HIER_AMDS_AMDC_MOTHERBOARD_0_S00_AXI_BASEADDR)
#endif

#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
#define MOTHERBOARD_MAX_IP_CORES (XPAR_AMDC_MOTHERBOARD_NUM_INSTANCES)
#define MOTHERBOARD_1_BASE_ADDR (XPAR_HIER_GPIO_0_HIER_AMDS_0_AMDC_MOTHERBOARD_0_S00_AXI_BASEADDR)
#define MOTHERBOARD_2_BASE_ADDR (XPAR_HIER_GPIO_1_HIER_AMDS_0_AMDC_MOTHERBOARD_0_S00_AXI_BASEADDR)
Expand Down Expand Up @@ -60,7 +60,7 @@ static inline uint32_t motherboard_idx_to_base_addr(int idx)
case 0:
return MOTHERBOARD_1_BASE_ADDR;

#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
case 1:
return MOTHERBOARD_2_BASE_ADDR;
case 2:
Expand Down
2 changes: 1 addition & 1 deletion sdk/app_cpu1/common/drv/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void pwm_set_all_rst(uint8_t rst)
}

// Hardware disabling of PWM was added to REV E hardware
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)

static bool is_pwm_enable_hw_enabled = false;

Expand Down
2 changes: 1 addition & 1 deletion sdk/app_cpu1/common/drv/pwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void pwm_init(void);
void pwm_toggle_reset(void);
void pwm_set_all_rst(uint8_t rst);

#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
int pwm_enable_hw(bool en);
#endif

Expand Down
11 changes: 8 additions & 3 deletions sdk/app_cpu1/common/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,19 @@

#include "xparameters.h"

// REV D has 2 GPIO ports, but only a single eddy current sensor driver IP block:
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_D) && (XPAR_AMDC_EDDY_CURRENT_SENSOR_NUM_INSTANCES != 1)
#error "ERROR: Vivado hardware target is REV E, but usr/user_config.h target is REV D!"
#endif

// REV E has 4 GPIO ports, each with their own eddy current sensor driver IP block:
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) && (XPAR_AMDC_EDDY_CURRENT_SENSOR_NUM_INSTANCES != 4)
#error "ERROR: Vivado hardware target is REV D, but usr/user_config.h target is REV E!"
#endif

// REV D has 2 GPIO ports, but only a single eddy current sensor driver IP block:
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_D) && (XPAR_AMDC_EDDY_CURRENT_SENSOR_NUM_INSTANCES != 1)
#error "ERROR: Vivado hardware target is REV E, but usr/user_config.h target is REV D!"
// REV F has 4 GPIO ports, each with their own eddy current sensor driver IP block:
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F) && (XPAR_AMDC_EDDY_CURRENT_SENSOR_NUM_INSTANCES != 4)
#error "ERROR: Vivado hardware target is REV D, but usr/user_config.h target is REV F!"
#endif

int main()
Expand Down
14 changes: 7 additions & 7 deletions sdk/app_cpu1/common/sys/cmd/cmd_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int cmd_hw(int argc, char **argv)
// Handle 'pwm' sub-command
if (argc >= 2 && STREQ("pwm", argv[1])) {
if (argc == 3 && STREQ("on", argv[2])) {
#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
// Turn on PWM hardware before enabling
// so that the first cycle has correct duty
pwm_enable_hw(true);
Expand All @@ -76,7 +76,7 @@ int cmd_hw(int argc, char **argv)
return CMD_FAILURE;
}

#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
// Turn off PWM hardware after disabling
// so that the last cycle has correct duty
pwm_enable_hw(false);
Expand Down Expand Up @@ -205,7 +205,7 @@ int cmd_hw(int argc, char **argv)
else
base_addr = EDDY_CURRENT_SENSOR_1_BASE_ADDR;

#elif USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#elif (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
if (port == 1)
base_addr = EDDY_CURRENT_SENSOR_1_BASE_ADDR;
else if (port == 2)
Expand Down Expand Up @@ -316,7 +316,7 @@ int cmd_hw(int argc, char **argv)
if (pin < 1 || pin > 2)
return CMD_INVALID_ARGUMENTS;

#elif USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#elif (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
if (gpio_port < 1 || gpio_port > 4)
return CMD_INVALID_ARGUMENTS;

Expand Down Expand Up @@ -379,7 +379,7 @@ int cmd_hw(int argc, char **argv)

gpio_mux_set_device(gpio_port - 1, device);

#elif USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#elif (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
if (device < 0 || device > GP3IO_MUX_DEVICE_COUNT) {
return CMD_INVALID_ARGUMENTS;
}
Expand Down Expand Up @@ -427,7 +427,7 @@ int cmd_hw(int argc, char **argv)
cmd_resp_print("8. UNUSED\r\n");
return CMD_SUCCESS;

#elif USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#elif (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
cmd_resp_print("AMDC REV E gpio device numbers:\r\n");
cmd_resp_print("1. AMDS\r\n");
cmd_resp_print("2. Eddy Current Sensor\r\n");
Expand Down Expand Up @@ -471,7 +471,7 @@ int cmd_hw(int argc, char **argv)
return CMD_SUCCESS;
*/

#elif USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#elif (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
cmd_resp_print("AMDC REV E sts device numbers:\r\n");
// TODO: FILL IN BELOW AND REMOVE NEXT LINE
cmd_resp_print("Please check the block design by opening hw/amdc_reve.bd in Vivado.\r\n");
Expand Down
2 changes: 1 addition & 1 deletion sdk/app_cpu1/common/sys/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void scheduler_run(void)
// data arrives before it is needed in the next control loop.
motherboard_request_new_data(MOTHERBOARD_1_BASE_ADDR);

#if USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E
#if (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_E) || (USER_CONFIG_HARDWARE_TARGET == AMDC_REV_F)
motherboard_request_new_data(MOTHERBOARD_2_BASE_ADDR);
motherboard_request_new_data(MOTHERBOARD_3_BASE_ADDR);
motherboard_request_new_data(MOTHERBOARD_4_BASE_ADDR);
Expand Down
4 changes: 2 additions & 2 deletions sdk/app_cpu1/user/usr/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// This file is used to override system defines and conditionally enable
// various system-level firmware features.

// Specify hardware revision (i.e. REV D, REV E, etc)
#define USER_CONFIG_HARDWARE_TARGET (AMDC_REV_E)
// Specify hardware revision (i.e. REV E, REV F, etc)
#define USER_CONFIG_HARDWARE_TARGET (AMDC_REV_F)

// Override the default scheduler elementary frequency by defining SYS_TICK_FREQ here.
// System uses 10kHz by default
Expand Down

0 comments on commit 2c70a07

Please sign in to comment.