-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
1 parent
474b730
commit 595ef6b
Showing
30 changed files
with
6,670 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build/ | ||
.idea/ | ||
cmake-build-debug/ |
1 change: 1 addition & 0 deletions
1
Firmware/CoverUI/CoverUI/.vscode/.cortex-debug.peripherals.state.json
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 @@ | ||
[] |
1 change: 1 addition & 0 deletions
1
Firmware/CoverUI/CoverUI/.vscode/.cortex-debug.registers.state.json
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 @@ | ||
[] |
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,17 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Linux", | ||
"includePath": [ | ||
"${workspaceFolder}/**" | ||
], | ||
"defines": [], | ||
"compilerPath": "/usr/local/bin/arm-none-eabi-gcc", | ||
"cStandard": "c11", | ||
"cppStandard": "gnu++14", | ||
"intelliSenseMode": "linux-gcc-arm", | ||
"compileCommands": "${workspaceFolder}/build/compile_commands.json" | ||
} | ||
], | ||
"version": 4 | ||
} |
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,22 @@ | ||
{ | ||
// Verwendet IntelliSense zum Ermitteln möglicher Attribute. | ||
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen. | ||
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "PICO Debug", | ||
"device": "RP2040", | ||
"gdbPath": "gdb-multiarch", | ||
"cwd": "${workspaceRoot}", | ||
"executable": "${command:cmake.launchTargetPath}", | ||
"request": "launch", | ||
"type": "cortex-debug", | ||
"servertype": "openocd", | ||
"configFiles": ["interface/picoprobe.cfg", "target/rp2040-core0.cfg"], | ||
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd", | ||
"runToMain": true, | ||
"postRestartCommands": ["break main", "continue"] | ||
} | ||
] | ||
} |
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 @@ | ||
{ | ||
"cortex-debug.variableUseNaturalFormat": true, | ||
"files.associations": { | ||
"initializer_list": "cpp", | ||
"utility": "cpp" | ||
} | ||
} |
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,28 @@ | ||
{ | ||
"tasks": [ | ||
{ | ||
"type": "cppbuild", | ||
"label": "C/C++: arm-none-eabi-gcc Aktive Datei kompilieren", | ||
"command": "/usr/bin/arm-none-eabi-gcc", | ||
"args": [ | ||
"-fdiagnostics-color=always", | ||
"-g", | ||
"${file}", | ||
"-o", | ||
"${fileDirname}/${fileBasenameNoExtension}" | ||
], | ||
"options": { | ||
"cwd": "${fileDirname}" | ||
}, | ||
"problemMatcher": [ | ||
"$gcc" | ||
], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"detail": "Vom Debugger generierte Aufgabe." | ||
} | ||
], | ||
"version": "2.0.0" | ||
} |
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,80 @@ | ||
#ifndef _BttnCtl_HEADER_FILE_ | ||
#define _BttnCtl_HEADER_FILE_ | ||
|
||
|
||
// Protocol Header Info | ||
enum TYPE | ||
{ | ||
Get_Version = 0xB0, | ||
Set_Buzzer = 0xB1, | ||
Set_LEDs = 0xB2, | ||
Get_Button = 0xB3 | ||
}; | ||
|
||
|
||
enum LED_state { | ||
LED_off = 0b000, | ||
LED_blink_slow = 0b101, | ||
LED_blink_fast = 0b110, | ||
LED_on = 0b111 | ||
}; | ||
|
||
#pragma pack(push, 1) | ||
struct msg_get_version | ||
{ | ||
uint8_t type; // command type | ||
uint8_t reserved; // padding | ||
uint16_t version; | ||
uint16_t crc; // CRC 16 | ||
} __attribute__((packed)); | ||
#pragma pack(pop) | ||
|
||
|
||
#pragma pack(push, 1) | ||
struct msg_set_buzzer | ||
{ | ||
uint8_t type; // command type | ||
uint8_t repeat; // Repeat X times | ||
uint8_t on_time; // Signal on time | ||
uint8_t off_time; // Signal off time | ||
uint16_t crc; // CRC 16 | ||
} __attribute__((packed)); | ||
#pragma pack(pop) | ||
|
||
|
||
/** | ||
* @brief Use this to update the LED matrix | ||
* Each LED gets three bits with the following meaning: | ||
* 0b000 = Off | ||
* 0b001 = reserved for future use | ||
* 0b010 = reserved for future use | ||
* 0b011 = reserved for future use | ||
* 0b100 = reserved for future use | ||
* 0b101 = On slow blink | ||
* 0b110 = On fast blink | ||
* 0b111 = On | ||
*/ | ||
#pragma pack(push, 1) | ||
struct msg_set_leds | ||
{ | ||
uint8_t type; // command type | ||
uint8_t reserved; // padding | ||
uint64_t leds; | ||
uint16_t crc; // CRC 16 | ||
} __attribute__((packed)); | ||
#pragma pack(pop) | ||
|
||
#pragma pack(push, 1) | ||
struct msg_event_button | ||
{ | ||
uint8_t type; // command type | ||
uint16_t button_id; | ||
uint8_t press_duration; | ||
uint16_t crc; // CRC 16 | ||
} __attribute__((packed)); | ||
#pragma pack(pop) | ||
|
||
|
||
|
||
|
||
#endif // _BttnCtl_HEADER_FILE_ |
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,46 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
include(pico_sdk_import.cmake) | ||
|
||
set(projname "mower-buttons") | ||
add_executable(${projname}) | ||
|
||
|
||
|
||
|
||
|
||
|
||
target_sources(${projname} PRIVATE main.cpp LEDcontrol.cpp statemachine.cpp buttonscan.cpp) | ||
|
||
#project(${projname} C CXX ASM) | ||
project(pico_examples C CXX ASM) | ||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
pico_sdk_init() | ||
|
||
#pico_generate_pio_header(${projname} ${CMAKE_CURRENT_LIST_DIR}/GPIO_prg.pio) | ||
pico_generate_pio_header(${projname} ${CMAKE_CURRENT_LIST_DIR}/status_LED.pio) | ||
pico_generate_pio_header(${projname} ${CMAKE_CURRENT_LIST_DIR}/LED_mux.pio) | ||
pico_generate_pio_header(${projname} ${CMAKE_CURRENT_LIST_DIR}/buzzer.pio) | ||
|
||
|
||
|
||
#set(Mower_PATH ${PROJECT_SOURCE_DIR}) | ||
set(PICO_EXAMPLES_PATH ${PROJECT_SOURCE_DIR}) | ||
|
||
|
||
|
||
# enable usb output, disable uart output | ||
# pico_enable_stdio_usb(mower-buttons 0) | ||
# pico_enable_stdio_uart(mower-buttons 1) | ||
|
||
|
||
|
||
|
||
# main.c | ||
# extrafunc.c | ||
# ) | ||
|
||
target_link_libraries(${projname} pico_stdlib hardware_pio pico_multicore) | ||
|
||
pico_add_extra_outputs(${projname}) |
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,127 @@ | ||
// | ||
// Copyright (c) 2011 Christopher Baker <https://christopherbaker.net> | ||
// Copyright (c) 2011 Jacques Fortier <https://github.com/jacquesf/COBS-Consistent-Overhead-Byte-Stuffing> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
|
||
#pragma once | ||
|
||
|
||
|
||
/// \brief A Consistent Overhead Byte Stuffing (COBS) Encoder. | ||
/// | ||
/// Consistent Overhead Byte Stuffing (COBS) is an encoding that removes all 0 | ||
/// bytes from arbitrary binary data. The encoded data consists only of bytes | ||
/// with values from 0x01 to 0xFF. This is useful for preparing data for | ||
/// transmission over a serial link (RS-232 or RS-485 for example), as the 0 | ||
/// byte can be used to unambiguously indicate packet boundaries. COBS also has | ||
/// the advantage of adding very little overhead (at least 1 byte, plus up to an | ||
/// additional byte per 254 bytes of data). For messages smaller than 254 bytes, | ||
/// the overhead is constant. | ||
/// | ||
/// \sa http://conferences.sigcomm.org/sigcomm/1997/papers/p062.pdf | ||
/// \sa http://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing | ||
/// \sa https://github.com/jacquesf/COBS-Consistent-Overhead-Byte-Stuffing | ||
/// \sa http://www.jacquesf.com/2011/03/consistent-overhead-byte-stuffing | ||
class COBS | ||
{ | ||
public: | ||
/// \brief Encode a byte buffer with the COBS encoder. | ||
/// \param buffer A pointer to the unencoded buffer to encode. | ||
/// \param size The number of bytes in the \p buffer. | ||
/// \param encodedBuffer The buffer for the encoded bytes. | ||
/// \returns The number of bytes written to the \p encodedBuffer. | ||
/// \warning The encodedBuffer must have at least getEncodedBufferSize() | ||
/// allocated. | ||
static size_t encode(const uint8_t* buffer, | ||
size_t size, | ||
uint8_t* encodedBuffer) | ||
{ | ||
size_t read_index = 0; | ||
size_t write_index = 1; | ||
size_t code_index = 0; | ||
uint8_t code = 1; | ||
|
||
while (read_index < size) | ||
{ | ||
if (buffer[read_index] == 0) | ||
{ | ||
encodedBuffer[code_index] = code; | ||
code = 1; | ||
code_index = write_index++; | ||
read_index++; | ||
} | ||
else | ||
{ | ||
encodedBuffer[write_index++] = buffer[read_index++]; | ||
code++; | ||
|
||
if (code == 0xFF) | ||
{ | ||
encodedBuffer[code_index] = code; | ||
code = 1; | ||
code_index = write_index++; | ||
} | ||
} | ||
} | ||
|
||
encodedBuffer[code_index] = code; | ||
|
||
return write_index; | ||
} | ||
|
||
|
||
/// \brief Decode a COBS-encoded buffer. | ||
/// \param encodedBuffer A pointer to the \p encodedBuffer to decode. | ||
/// \param size The number of bytes in the \p encodedBuffer. | ||
/// \param decodedBuffer The target buffer for the decoded bytes. | ||
/// \returns The number of bytes written to the \p decodedBuffer. | ||
/// \warning decodedBuffer must have a minimum capacity of size. | ||
static size_t decode(const uint8_t* encodedBuffer, | ||
size_t size, | ||
uint8_t* decodedBuffer) | ||
{ | ||
if (size == 0) | ||
return 0; | ||
|
||
size_t read_index = 0; | ||
size_t write_index = 0; | ||
uint8_t code = 0; | ||
uint8_t i = 0; | ||
|
||
while (read_index < size) | ||
{ | ||
code = encodedBuffer[read_index]; | ||
|
||
if (read_index + code > size && code != 1) | ||
{ | ||
return 0; | ||
} | ||
|
||
read_index++; | ||
|
||
for (i = 1; i < code; i++) | ||
{ | ||
decodedBuffer[write_index++] = encodedBuffer[read_index++]; | ||
} | ||
|
||
if (code != 0xFF && read_index != size) | ||
{ | ||
decodedBuffer[write_index++] = '\0'; | ||
} | ||
} | ||
|
||
return write_index; | ||
} | ||
|
||
/// \brief Get the maximum encoded buffer size for an unencoded buffer size. | ||
/// \param unencodedBufferSize The size of the buffer to be encoded. | ||
/// \returns the maximum size of the required encoded buffer. | ||
static size_t getEncodedBufferSize(size_t unencodedBufferSize) | ||
{ | ||
return unencodedBufferSize + unencodedBufferSize / 254 + 1; | ||
} | ||
|
||
}; |
Oops, something went wrong.