Skip to content

Commit

Permalink
WIP serial Arduino
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-rabault committed Jul 17, 2023
1 parent ab7abb3 commit c90100a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
10 changes: 4 additions & 6 deletions examples/projects/Arduino/button/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
default_envs = zero

[env]
lib_extra_dirs =
lib_extra_dirs =
$PROJECT_DIR/../../../../../
$PROJECT_DIR/../../../../network/
lib_ldf_mode =off
Expand All @@ -34,17 +34,15 @@ build_unflags = -Os
build_flags =
-O1
-include node_config.h
-D LUOSHAL=ATSAMD21_ARDUINO
-D LUOSHAL=ARDUINO
-D SERIAL_COM_DEFAULTBAUDRATE=115200
lib_deps =
luos_engine@^3.0.0
robus_network
serial_network
Button


[env:zero]
board = mkrzero
platform_packages = framework-arduino-samd@https://github.com/Luos-io/Arduino_core.git


[env:seed]
board = seeed_xiao
Expand Down
5 changes: 3 additions & 2 deletions examples/projects/Arduino/button/src/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern "C"
#endif

#include "luos_engine.h"
#include "robus_network.h"
#include "serial_network.h"
#include "button.h"

#ifdef __cplusplus
Expand All @@ -21,7 +21,7 @@ extern "C"
void setup()
{
Luos_Init();
Robus_Init();
Serial_Init();
Button_Init();
}
/******************************************************************************
Expand All @@ -32,5 +32,6 @@ void setup()
void loop()
{
Luos_Loop();
Serial_Loop();
Button_Loop();
}
1 change: 0 additions & 1 deletion examples/projects/Arduino/led/lib/led/led.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#define LED_H

#include "luos_engine.h"
#include "robus_network.h"

/*******************************************************************************
* Definitions
Expand Down
5 changes: 3 additions & 2 deletions examples/projects/Arduino/led/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ build_flags =
-O1
-include node_config.h
-D LUOSHAL=ATSAMD21_ARDUINO
-D SERIALHAL=ARDUINO
lib_deps =
luos_engine@^3.0.0
robus_network
serial_network
Led


[env:zero]
board = mkrzero
platform_packages = framework-arduino-samd@https://github.com/Luos-io/Arduino_core.git
; platform_packages = framework-arduino-samd@https://github.com/Luos-io/Arduino_core.git


[env:seed]
Expand Down
5 changes: 3 additions & 2 deletions examples/projects/Arduino/led/src/led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern "C"
#endif

#include "luos_engine.h"
#include "robus_network.h"
#include "serial_network.h"
#include "led.h"

#ifdef __cplusplus
Expand All @@ -21,7 +21,7 @@ extern "C"
void setup()
{
Luos_Init();
Robus_Init();
Serial_Init();
Led_Init();
}
/******************************************************************************
Expand All @@ -32,5 +32,6 @@ void setup()
void loop()
{
Luos_Loop();
Serial_Loop();
Led_Loop();
}
6 changes: 5 additions & 1 deletion network/serial_network/HAL/ARDUINO/serial_network_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ extern "C"
void SerialHAL_Init(uint8_t *rx_buffer, uint32_t buffer_size)
{
Serial.begin(SERIAL_COM_DEFAULTBAUDRATE);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
}

/******************************************************************************
Expand All @@ -46,8 +48,10 @@ void SerialHAL_Loop(void)
uint8_t data = 0;
while (Serial.available() > 0)
{
data = Serial.read();
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
data = Serial.read(); // say what you got:
Serial_ReceptionAdd(&data, 1);
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
}
}

Expand Down
1 change: 1 addition & 0 deletions network/serial_network/HAL/NATIVE/serial_network_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ void SerialHAL_Init(uint8_t *rx_buffer, uint32_t buffer_size)
LUOS_ASSERT(0);
}
#endif
sleep(2);
}

/******************************************************************************
Expand Down

0 comments on commit c90100a

Please sign in to comment.