Skip to content

Commit

Permalink
enabled second port
Browse files Browse the repository at this point in the history
  • Loading branch information
vChavezB committed May 23, 2024
1 parent 034e06c commit b07b29c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
compatible = "gpio-leds";
iolm_irq: iolm_irq {
status = "okay";
gpios = <&gpio0 26 (GPIO_ACTIVE_LOW)>;
gpios = <&gpio0 18 (GPIO_ACTIVE_LOW)>;
label = "iolm_irq";
};
iolm_cs: iolm_cs {
status = "okay";
gpios = <&gpio0 27 (GPIO_ACTIVE_LOW)>;
gpios = <&gpio0 19 (GPIO_ACTIVE_LOW)>;
label = "iolm_cs";
};
};
Expand Down
19 changes: 17 additions & 2 deletions samples/ifm_sample_app/src/iol_master_sample_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static const struct device *const spi_dev = DEVICE_DT_GET(DT_ALIAS(iolm_spi));
static const struct gpio_dt_spec irq_dev = GPIO_DT_SPEC_GET(DT_ALIAS(iolm_irq), gpios);

#define IOLINK_HANDLER_THREAD_STACK_SIZE (8192)
#define IOLINK_HANDLER_THREAD_PRIO 4
#define IOLINK_HANDLER_THREAD_PRIO 5
static K_THREAD_STACK_DEFINE(iolm_handler_stack, IOLINK_HANDLER_THREAD_STACK_SIZE);


Expand Down Expand Up @@ -86,13 +86,25 @@ static iolink_m_cfg_t iolink_cfg = {

os_thread_t * iolink_handler_thread;
iolink_hw_drv_t * hw[2];
#define CURR_100MA 0x00
#define CURR_200MA 0x01
#define CURR_300MA 0x02
#define CURR_500MA 0x03
#define DRVRCURRLIM_CLDIS BIT(5)

#define CURR_OFF 0x06

#define CL_CONF(x) ((x) << CURR_OFF)
static const iolink_14819_cfg_t iol_14819_0_cfg = {
.chip_address = IOLINK_APP_CHIP0_ADDRESS,
.spi_slave_name = spi_dev,
.CQCfgA = MAX14819_CQCFG_DRVDIS | MAX14819_CQCFG_SINKSEL(0x2),
.CQCfgB = MAX14819_CQCFG_DRVDIS | MAX14819_CQCFG_SINKSEL(0x2),
.LPCnfgA = MAX14819_LPCNFG_LPEN,
.LPCnfgB = MAX14819_LPCNFG_LPEN,
.IOStCfgA = MAX14819_IOSTCFG_DICSINK | MAX14819_IOSTCFG_DIEC3TH,
.DrvCurrLim = 0x00,
.IOStCfgB = MAX14819_IOSTCFG_DICSINK | MAX14819_IOSTCFG_DIEC3TH,
.DrvCurrLim = CL_CONF(CURR_300MA),
.Clock = MAX14819_CLOCK_XTALEN | MAX14819_CLOCK_TXTXENDIS,
};

Expand Down Expand Up @@ -142,6 +154,9 @@ int main(void)

LOG_INF("Starting app");
hw[0] = main_14819_init("/iolink0", &iol_14819_0_cfg, irq_dev.port, irq_dev.pin);
if (hw[0] == NULL) {
return 0;
}
#ifdef IOLINK_APP_CHIP1_SPI
hw[1] = main_14819_init("/iolink1", &iol_14819_1_cfg, irq_dev.port, irq_dev.pin);
#endif
Expand Down
8 changes: 4 additions & 4 deletions samples/ifm_sample_app/src/iolink_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void generic_app (iolink_app_port_ctx_t * app_port)
static uint8_t iolink_start_port (iolink_app_port_ctx_t * app_port)
{
iolink_app_port_status_t * port_status = &app_port->status;
uint8_t portnumber = app_port->portnumber;
uint8_t portnumber = app_port->portnumber-1;

if (get_port_status (app_port) != 0)
{
Expand Down Expand Up @@ -420,7 +420,7 @@ void iolink_handler (iolink_m_cfg_t m_cfg)
for (size_t i = 0; i < app_port->pdin.data_len; i++) {
sprintf(pdin_data + (i * 2), "%02x", app_port->pdin.data[i]);
}
//LOG_INF("Port [%d] PDIN Cnf %s", app_port->portnumber,pdin_data);
LOG_INF("Port [%d] PDIN Cnf %s", app_port->portnumber,pdin_data);
}
}

Expand Down Expand Up @@ -520,8 +520,8 @@ static void handle_smi_portevent (
uint8_t portnumber = app_port->portnumber;
iolink_app_master_ctx_t * app_master = app_port->app_master;
uint8_t port_index = portnumber - 1;
LOG_INF("SMI event");
LOG_INF("Port event %d : %x",event->event_qualifier,event->event_code);
//LOG_INF("SMI event");
//LOG_INF("Port [%d] event %d : %x",port_index,event->event_qualifier,event->event_code);
if (
((app_port->type == GOLDEN) || (app_port->type == UNKNOWN)) &&
event->event_code != IOLINK_EVENTCODE_NO_DEV)
Expand Down
2 changes: 1 addition & 1 deletion samples/ifm_sample_app/src/iolink_smi.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int8_t do_smi_pdin (iolink_app_port_ctx_t * app_port, bool * valid)
memset (&arg_block_void, 0, sizeof (arg_block_void_t));
arg_block_void.arg_block.id = IOLINK_ARG_BLOCK_ID_VOID_BLOCK;

SMI_PDIn_req (
return SMI_PDIn_req (
app_port->portnumber,
IOLINK_ARG_BLOCK_ID_PD_IN,
sizeof (arg_block_void_t),
Expand Down

0 comments on commit b07b29c

Please sign in to comment.