-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
847 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* Copyright (c) 2024 Victor Chavez | ||
SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
#pragma once | ||
|
||
|
||
int iolm_init(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
/** | ||
* @brief Decode IOL-Device cycle time | ||
* @details See IO-Link v1.1.3 Table B.15 | ||
* | ||
* @param encoded_time Encoded Cycle Time | ||
* @return uint32_t Cycle time in microseconds | ||
*/ | ||
uint32_t cyctime_decode_us(uint8_t encoded_time); | ||
|
||
/** | ||
* @brief Encode IOL-Device cycle time | ||
* @details See IO-Link v1.1.3 Table B.15 | ||
* @param CycleTimeUs Cycle time in microseconds | ||
* @return uint8_t Encoded Cycle Time according to spec | ||
*/ | ||
uint8_t cyctime_encode(uint32_t cycletime_us); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) 2024 Victor Chavez | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
set(IOLINK_MODULE ${CMAKE_CURRENT_SOURCE_DIR}/../..) | ||
set(ZEPHYR_EXTRA_MODULES ${IOLINK_MODULE}) | ||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(iolm_demo) | ||
|
||
target_sources(app PRIVATE src/iolink_smi.c | ||
src/iolink_handler.c | ||
src/demo.c | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) 2024 Victor Chavez | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
set(IOLINK_MODULE ${CMAKE_CURRENT_SOURCE_DIR}/../..) | ||
set(ZEPHYR_EXTRA_MODULES ${IOLINK_MODULE}) | ||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(iolm_demo) | ||
|
||
target_sources(app PRIVATE src/main.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Zephyr IOLM Read Process Data Input | ||
|
||
A sample application that demonstrates how to read PDIn from an IO-Link device | ||
|
||
|
||
## Build and Flash | ||
|
||
``` | ||
git clone --recursive https://github.com/vChavezB/zephyr-iolm/ | ||
cd YOUR_ZEPHYR_WEST_WORKSPACE | ||
west build zephyr-iolm/samples/read_pd -b YOUR_BOARD | ||
west flash | ||
``` | ||
|
||
Where: | ||
|
||
- YOUR_ZEPHYR_WEST_WORKSPACE: Is the installation of your Zephyr SDK (i.e. `west init ..`). | ||
Note: This has only been tested with Zephyr revision v3.6.99 commit `34c84eccec0508b16f5001b20fa369f387d856df` | ||
- `YOUR_BOARD`: `esp32`, `nrf52833dk_nrf52833` | ||
|
||
## Expected Output |
16 changes: 16 additions & 0 deletions
16
samples/read_pd/boards/esp32_devkitc_wrover_procpu.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
&uart0 { | ||
current-speed = <460800>; | ||
}; | ||
|
||
&spi2 { | ||
status = "okay"; | ||
cs-gpios = <&gpio0 19 GPIO_ACTIVE_LOW>; | ||
max:maxim14819@0 { | ||
spi-max-frequency = <8000000>; | ||
status = "okay"; | ||
irq-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>; | ||
compatible = "iolm,maxim14819"; | ||
reg = <0x00>; | ||
chip-address = <0x00>; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
&uart0 { | ||
current-speed = <460800>; | ||
}; | ||
|
||
&pinctrl { | ||
|
||
spi1_default: spi1_default { | ||
group1 { | ||
psels = <NRF_PSEL(SPIM_SCK, 0, 31)>, | ||
<NRF_PSEL(SPIM_MOSI, 0, 30)>, | ||
<NRF_PSEL(SPIM_MISO, 0,29)>; | ||
}; | ||
}; | ||
|
||
spi1_sleep: spi1_sleep { | ||
group1 { | ||
psels = <NRF_PSEL(SPIM_SCK, 0, 31)>, | ||
<NRF_PSEL(SPIM_MOSI, 0, 30)>, | ||
<NRF_PSEL(SPIM_MISO, 0, 29)>; | ||
low-power-enable; | ||
}; | ||
}; | ||
}; | ||
|
||
//#include <iolm/maxim14819.h> | ||
|
||
&spi1 { | ||
status = "okay"; | ||
pinctrl-names = "default", "sleep"; | ||
cs-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; | ||
max:maxim14819@0 { | ||
spi-max-frequency = <10000000>; | ||
status = "okay"; | ||
irq-gpios = <&gpio0 28 GPIO_ACTIVE_LOW>; | ||
compatible = "iolm,maxim14819"; | ||
reg = <0x00>; | ||
chip-address = <0x00>; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) 2024 Victor Chavez | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
CONFIG_THREAD_NAME=y | ||
CONFIG_LOG=y | ||
CONFIG_IOLINK_LOG_LEVEL_DBG=y | ||
CONFIG_ASSERT=y | ||
CONFIG_MINIMAL_LIBC=y | ||
#CONFIG_LOG_BUFFER_SIZE=16384 | ||
CONFIG_IOLINK=y | ||
CONFIG_IOLINK_MAIN_STACK_SIZE=1024 | ||
CONFIG_IOLINK_DL_STACK_SIZE=1024 | ||
CONFIG_IOLINK_NUM_PORTS=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* Copyright (c) 2024 Victor Chavez | ||
SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
#include <iolm/iolm.h> | ||
#include <zephyr/kernel.h> | ||
|
||
int main(void) | ||
{ | ||
int rc = iolm_init(); | ||
if (rc != 0) { | ||
printk("Failed to initialize IO-Link Master: %d\n",rc); | ||
} | ||
return rc; | ||
} |
Oops, something went wrong.