Skip to content

Commit

Permalink
initial draft for alpha version
Browse files Browse the repository at this point in the history
  • Loading branch information
vChavezB committed May 25, 2024
1 parent 0f6cf33 commit c5d00d7
Show file tree
Hide file tree
Showing 13 changed files with 847 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ if(CONFIG_IOLINK)
${STACK_SRC}/iolink_sm.c
src/osal/osal.c
src/osal/osal_log.c
src/iolm.c
src/utils.c
src/transciever.c)

#zephyr_library_sources_ifdef(CONFIG_XX xx)
Expand Down
7 changes: 7 additions & 0 deletions include/iolm/iolm.h
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);
1 change: 1 addition & 0 deletions include/iolm/transciever.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <osal.h>
#include <iolink_pl_hw_drv.h>
#include <stdint.h>

Expand Down
20 changes: 20 additions & 0 deletions include/iolm/utils.h
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);
13 changes: 13 additions & 0 deletions samples/buzzer/CMakeLists.txt
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
)
10 changes: 10 additions & 0 deletions samples/read_pd/CMakeLists.txt
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)
21 changes: 21 additions & 0 deletions samples/read_pd/README.md
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 samples/read_pd/boards/esp32_devkitc_wrover_procpu.overlay
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>;
};
};
39 changes: 39 additions & 0 deletions samples/read_pd/boards/nrf52833dk_nrf52833.overlay
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>;
};
};
13 changes: 13 additions & 0 deletions samples/read_pd/prj.conf
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
14 changes: 14 additions & 0 deletions samples/read_pd/src/main.c
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;
}
Loading

0 comments on commit c5d00d7

Please sign in to comment.