Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,24 @@
"_CONFIG_DFLT_BUZZER_FREQUENCY=700",
"_CONFIG_DFLT_LED_STATUS_ENABLED=true",
"_CONFIG_DFLT_LED_KEY_ENABLED=true",
"_CONFIG_DFLT_INPUT_TYPE_TRS_0_TIP=INPUT_TYPE_STRAIGHT_KEY",
"_CONFIG_DFLT_INPUT_POLARITY_TRS_0_TIP=INPUT_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_INPUT_TYPE_TRS_0_RING=INPUT_TYPE_NONE",
"_CONFIG_DFLT_INPUT_POLARITY_TRS_0_RING=INPUT_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_INPUT_TYPE_TRS_1_TIP=INPUT_TYPE_PADDLE_LEFT",
"_CONFIG_DFLT_INPUT_POLARITY_TRS_1_TIP=INPUT_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_INPUT_TYPE_TRS_1_RING=INPUT_TYPE_PADDLE_RIGHT",
"_CONFIG_DFLT_INPUT_POLARITY_TRS_1_RING=INPUT_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_INPUT_TYPE_TRS_2_TIP=INPUT_TYPE_NONE",
"_CONFIG_DFLT_INPUT_POLARITY_TRS_2_TIP=INPUT_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_INPUT_TYPE_TRS_2_RING=INPUT_TYPE_NONE",
"_CONFIG_DFLT_INPUT_POLARITY_TRS_2_RING=INPUT_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_IO_TYPE_TRS_0_TIP=IO_TYPE_INPUT_STRAIGHT_KEY",
"_CONFIG_DFLT_IO_POLARITY_TRS_0_TIP=IO_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_IO_TYPE_TRS_0_RING=IO_TYPE_NONE",
"_CONFIG_DFLT_IO_POLARITY_TRS_0_RING=IO_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_IO_TYPE_TRS_1_TIP=IO_TYPE_INPUT_PADDLE_LEFT",
"_CONFIG_DFLT_IO_POLARITY_TRS_1_TIP=IO_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_IO_TYPE_TRS_1_RING=IO_TYPE_INPUT_PADDLE_RIGHT",
"_CONFIG_DFLT_IO_POLARITY_TRS_1_RING=IO_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_IO_TYPE_TRS_2_TIP=IO_TYPE_NONE",
"_CONFIG_DFLT_IO_POLARITY_TRS_2_TIP=IO_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_IO_TYPE_TRS_2_RING=IO_TYPE_NONE",
"_CONFIG_DFLT_IO_POLARITY_TRS_2_RING=IO_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_IO_TYPE_TRS_3_TIP=IO_TYPE_OUTPUT_KEYER",
"_CONFIG_DFLT_IO_POLARITY_TRS_3_TIP=IO_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_IO_TYPE_TRS_3_RING=IO_TYPE_NONE",
"_CONFIG_DFLT_IO_POLARITY_TRS_3_RING=IO_POLARITY_ACTIVE_LOW",
"_CONFIG_DFLT_KEYER_PADDLE_MODE=KEYER_PADDLE_MODE_IAMBIC",
"_CONFIG_DFLT_KEYER_PADDLE_INVERT=false",
"_CONFIG_DFLT_KEYER_OUTPUT_ACTIVE_LOW=true"
"_CONFIG_DFLT_KEYER_PADDLE_INVERT=false"
],
"compilerPath": "/usr/bin/avr-gcc",
"compilerArgs": [
Expand Down
84 changes: 48 additions & 36 deletions configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,38 @@ set(CONFIG_DFLT_LED_STATUS_ENABLED true
CACHE STRING "Is the status LED enabled? (true / false)")
set(CONFIG_DFLT_LED_KEY_ENABLED true
CACHE STRING "Is the key LED enabled? (true / false)")
set(CONFIG_DFLT_INPUT_TYPE_TRS_0_TIP INPUT_TYPE_STRAIGHT_KEY
CACHE STRING "Input type for the tip of TRS 0. (input_type_t)")
set(CONFIG_DFLT_INPUT_POLARITY_TRS_0_TIP INPUT_POLARITY_ACTIVE_LOW
CACHE STRING "Input polarity for the tip of TRS 0. (input_polarity_t)")
set(CONFIG_DFLT_INPUT_TYPE_TRS_0_RING INPUT_TYPE_NONE
CACHE STRING "Input type for the ring of TRS 0. (input_type_t)")
set(CONFIG_DFLT_INPUT_POLARITY_TRS_0_RING INPUT_POLARITY_ACTIVE_LOW
CACHE STRING "Input polarity for the ring of TRS 0. (input_polarity_t)")
set(CONFIG_DFLT_INPUT_TYPE_TRS_1_TIP INPUT_TYPE_PADDLE_LEFT
CACHE STRING "Input type for the tip of TRS 0. (input_type_t)")
set(CONFIG_DFLT_INPUT_POLARITY_TRS_1_TIP INPUT_POLARITY_ACTIVE_LOW
CACHE STRING "Input polarity for the tip of TRS 0. (input_polarity_t)")
set(CONFIG_DFLT_INPUT_TYPE_TRS_1_RING INPUT_TYPE_PADDLE_RIGHT
CACHE STRING "Input type for the ring of TRS 0. (input_type_t)")
set(CONFIG_DFLT_INPUT_POLARITY_TRS_1_RING INPUT_POLARITY_ACTIVE_LOW
CACHE STRING "Input polarity for the ring of TRS 0. (input_polarity_t)")
set(CONFIG_DFLT_INPUT_TYPE_TRS_2_TIP INPUT_TYPE_NONE
CACHE STRING "Input type for the tip of TRS 0. (input_type_t)")
set(CONFIG_DFLT_INPUT_POLARITY_TRS_2_TIP INPUT_POLARITY_ACTIVE_LOW
CACHE STRING "Input polarity for the tip of TRS 0. (input_polarity_t)")
set(CONFIG_DFLT_INPUT_TYPE_TRS_2_RING INPUT_TYPE_NONE
CACHE STRING "Input type for the ring of TRS 0. (input_type_t)")
set(CONFIG_DFLT_INPUT_POLARITY_TRS_2_RING INPUT_POLARITY_ACTIVE_LOW
CACHE STRING "Input polarity for the ring of TRS 0. (input_polarity_t)")
set(CONFIG_DFLT_IO_TYPE_TRS_0_TIP IO_TYPE_INPUT_STRAIGHT_KEY
CACHE STRING "I/O type for the tip of TRS 0. (io_type_t)")
set(CONFIG_DFLT_IO_POLARITY_TRS_0_TIP IO_POLARITY_ACTIVE_LOW
CACHE STRING "I/O polarity for the tip of TRS 0. (io_polarity_t)")
set(CONFIG_DFLT_IO_TYPE_TRS_0_RING IO_TYPE_NONE
CACHE STRING "I/O type for the ring of TRS 0. (io_type_t)")
set(CONFIG_DFLT_IO_POLARITY_TRS_0_RING IO_POLARITY_ACTIVE_LOW
CACHE STRING "I/O polarity for the ring of TRS 0. (io_polarity_t)")
set(CONFIG_DFLT_IO_TYPE_TRS_1_TIP IO_TYPE_INPUT_PADDLE_LEFT
CACHE STRING "I/O type for the tip of TRS 1. (io_type_t)")
set(CONFIG_DFLT_IO_POLARITY_TRS_1_TIP IO_POLARITY_ACTIVE_LOW
CACHE STRING "I/O polarity for the tip of TRS 1. (io_polarity_t)")
set(CONFIG_DFLT_IO_TYPE_TRS_1_RING IO_TYPE_INPUT_PADDLE_RIGHT
CACHE STRING "I/O type for the ring of TRS 1. (io_type_t)")
set(CONFIG_DFLT_IO_POLARITY_TRS_1_RING IO_POLARITY_ACTIVE_LOW
CACHE STRING "I/O polarity for the ring of TRS 1. (io_polarity_t)")
set(CONFIG_DFLT_IO_TYPE_TRS_2_TIP IO_TYPE_NONE
CACHE STRING "I/O type for the tip of TRS 2. (io_type_t)")
set(CONFIG_DFLT_IO_POLARITY_TRS_2_TIP IO_POLARITY_ACTIVE_LOW
CACHE STRING "I/O polarity for the tip of TRS 2. (io_polarity_t)")
set(CONFIG_DFLT_IO_TYPE_TRS_2_RING IO_TYPE_NONE
CACHE STRING "I/O type for the ring of TRS 2. (io_type_t)")
set(CONFIG_DFLT_IO_POLARITY_TRS_2_RING IO_POLARITY_ACTIVE_LOW
CACHE STRING "I/O polarity for the ring of TRS 2. (io_polarity_t)")
set(CONFIG_DFLT_IO_TYPE_TRS_3_TIP IO_TYPE_OUTPUT_KEYER
CACHE STRING "I/O type for the tip of TRS 3. (io_type_t)")
set(CONFIG_DFLT_IO_POLARITY_TRS_3_TIP IO_POLARITY_ACTIVE_LOW
CACHE STRING "I/O polarity for the tip of TRS 3. (io_polarity_t)")
set(CONFIG_DFLT_IO_TYPE_TRS_3_RING IO_TYPE_NONE
CACHE STRING "I/O type for the ring of TRS 3. (io_type_t)")
set(CONFIG_DFLT_IO_POLARITY_TRS_3_RING IO_POLARITY_ACTIVE_LOW
CACHE STRING "I/O polarity for the ring of TRS 3. (io_polarity_t)")
set(CONFIG_DFLT_KEYER_PADDLE_MODE KEYER_PADDLE_MODE_IAMBIC
CACHE STRING "Keyer paddle mode. (keyer_paddle_mode_t)")
set(CONFIG_DFLT_KEYER_PADDLE_INVERT false
Expand All @@ -63,18 +71,22 @@ add_compile_definitions(
_CONFIG_DFLT_LED_STATUS_ACTIVE_LO=${CONFIG_DFLT_LED_STATUS_ACTIVE_LO}
_CONFIG_DFLT_LED_KEY_ENABLED=${CONFIG_DFLT_LED_KEY_ENABLED}
_CONFIG_DFLT_LED_KEY_ACTIVE_LO=${CONFIG_DFLT_LED_KEY_ACTIVE_LO}
_CONFIG_DFLT_INPUT_TYPE_TRS_0_TIP=${CONFIG_DFLT_INPUT_TYPE_TRS_0_TIP}
_CONFIG_DFLT_INPUT_POLARITY_TRS_0_TIP=${CONFIG_DFLT_INPUT_POLARITY_TRS_0_TIP}
_CONFIG_DFLT_INPUT_TYPE_TRS_0_RING=${CONFIG_DFLT_INPUT_TYPE_TRS_0_RING}
_CONFIG_DFLT_INPUT_POLARITY_TRS_0_RING=${CONFIG_DFLT_INPUT_POLARITY_TRS_0_RING}
_CONFIG_DFLT_INPUT_TYPE_TRS_1_TIP=${CONFIG_DFLT_INPUT_TYPE_TRS_1_TIP}
_CONFIG_DFLT_INPUT_POLARITY_TRS_1_TIP=${CONFIG_DFLT_INPUT_POLARITY_TRS_1_TIP}
_CONFIG_DFLT_INPUT_TYPE_TRS_1_RING=${CONFIG_DFLT_INPUT_TYPE_TRS_1_RING}
_CONFIG_DFLT_INPUT_POLARITY_TRS_1_RING=${CONFIG_DFLT_INPUT_POLARITY_TRS_1_RING}
_CONFIG_DFLT_INPUT_TYPE_TRS_2_TIP=${CONFIG_DFLT_INPUT_TYPE_TRS_2_TIP}
_CONFIG_DFLT_INPUT_POLARITY_TRS_2_TIP=${CONFIG_DFLT_INPUT_POLARITY_TRS_2_TIP}
_CONFIG_DFLT_INPUT_TYPE_TRS_2_RING=${CONFIG_DFLT_INPUT_TYPE_TRS_2_RING}
_CONFIG_DFLT_INPUT_POLARITY_TRS_2_RING=${CONFIG_DFLT_INPUT_POLARITY_TRS_2_RING}
_CONFIG_DFLT_IO_TYPE_TRS_0_TIP=${CONFIG_DFLT_IO_TYPE_TRS_0_TIP}
_CONFIG_DFLT_IO_POLARITY_TRS_0_TIP=${CONFIG_DFLT_IO_POLARITY_TRS_0_TIP}
_CONFIG_DFLT_IO_TYPE_TRS_0_RING=${CONFIG_DFLT_IO_TYPE_TRS_0_RING}
_CONFIG_DFLT_IO_POLARITY_TRS_0_RING=${CONFIG_DFLT_IO_POLARITY_TRS_0_RING}
_CONFIG_DFLT_IO_TYPE_TRS_1_TIP=${CONFIG_DFLT_IO_TYPE_TRS_1_TIP}
_CONFIG_DFLT_IO_POLARITY_TRS_1_TIP=${CONFIG_DFLT_IO_POLARITY_TRS_1_TIP}
_CONFIG_DFLT_IO_TYPE_TRS_1_RING=${CONFIG_DFLT_IO_TYPE_TRS_1_RING}
_CONFIG_DFLT_IO_POLARITY_TRS_1_RING=${CONFIG_DFLT_IO_POLARITY_TRS_1_RING}
_CONFIG_DFLT_IO_TYPE_TRS_2_TIP=${CONFIG_DFLT_IO_TYPE_TRS_2_TIP}
_CONFIG_DFLT_IO_POLARITY_TRS_2_TIP=${CONFIG_DFLT_IO_POLARITY_TRS_2_TIP}
_CONFIG_DFLT_IO_TYPE_TRS_2_RING=${CONFIG_DFLT_IO_TYPE_TRS_2_RING}
_CONFIG_DFLT_IO_POLARITY_TRS_2_RING=${CONFIG_DFLT_IO_POLARITY_TRS_2_RING}
_CONFIG_DFLT_IO_TYPE_TRS_3_TIP=${CONFIG_DFLT_IO_TYPE_TRS_3_TIP}
_CONFIG_DFLT_IO_POLARITY_TRS_3_TIP=${CONFIG_DFLT_IO_POLARITY_TRS_3_TIP}
_CONFIG_DFLT_IO_TYPE_TRS_3_RING=${CONFIG_DFLT_IO_TYPE_TRS_3_RING}
_CONFIG_DFLT_IO_POLARITY_TRS_3_RING=${CONFIG_DFLT_IO_POLARITY_TRS_3_RING}
_CONFIG_DFLT_KEYER_PADDLE_MODE=${CONFIG_DFLT_KEYER_PADDLE_MODE}
_CONFIG_DFLT_KEYER_PADDLE_INVERT=${CONFIG_DFLT_KEYER_PADDLE_INVERT}
_CONFIG_DFLT_KEYER_OUTPUT_ACTIVE_LOW=${CONFIG_DFLT_KEYER_OUTPUT_ACTIVE_LOW}
Expand Down
4 changes: 2 additions & 2 deletions src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ set(EXECUTABLE_SOURCE application/buzzer.c
application/config.h
application/debug_port.c
application/debug_port.h
application/input.c
application/input.h
application/io.c
application/io.h
application/keyer.c
application/keyer.h
application/led.c
Expand Down
33 changes: 18 additions & 15 deletions src/main/application/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <string.h>

#include "application/config.h"
#include "application/input.h"
#include "application/keyer.h"
#include "application/led.h"
#include "application/storage.h"
Expand Down Expand Up @@ -83,24 +82,28 @@ void config_default( config_t * config )
config->led_enabled[ LED_STATUS ] = _CONFIG_DFLT_LED_STATUS_ENABLED;
config->led_enabled[ LED_KEY ] = _CONFIG_DFLT_LED_KEY_ENABLED;

// Input configuration
config->input_type[ INPUT_PIN_TRS_0_TIP ] = _CONFIG_DFLT_INPUT_TYPE_TRS_0_TIP;
config->input_polarity[ INPUT_PIN_TRS_0_TIP ] = _CONFIG_DFLT_INPUT_POLARITY_TRS_0_TIP;
config->input_type[ INPUT_PIN_TRS_0_RING ] = _CONFIG_DFLT_INPUT_TYPE_TRS_0_RING;
config->input_polarity[ INPUT_PIN_TRS_0_RING ] = _CONFIG_DFLT_INPUT_POLARITY_TRS_0_RING;
config->input_type[ INPUT_PIN_TRS_1_TIP ] = _CONFIG_DFLT_INPUT_TYPE_TRS_1_TIP;
config->input_polarity[ INPUT_PIN_TRS_1_TIP ] = _CONFIG_DFLT_INPUT_POLARITY_TRS_1_TIP;
config->input_type[ INPUT_PIN_TRS_1_RING ] = _CONFIG_DFLT_INPUT_TYPE_TRS_1_RING;
config->input_polarity[ INPUT_PIN_TRS_1_RING ] = _CONFIG_DFLT_INPUT_POLARITY_TRS_1_RING;
config->input_type[ INPUT_PIN_TRS_2_TIP ] = _CONFIG_DFLT_INPUT_TYPE_TRS_2_TIP;
config->input_polarity[ INPUT_PIN_TRS_2_TIP ] = _CONFIG_DFLT_INPUT_POLARITY_TRS_2_TIP;
config->input_type[ INPUT_PIN_TRS_2_RING ] = _CONFIG_DFLT_INPUT_TYPE_TRS_2_RING;
config->input_polarity[ INPUT_PIN_TRS_2_RING ] = _CONFIG_DFLT_INPUT_POLARITY_TRS_2_RING;
// I/O configuration
// TODO: Compile-time constants
config->io_type[ IO_PIN_TRS_0_TIP ] = _CONFIG_DFLT_IO_TYPE_TRS_0_TIP;
config->io_polarity[ IO_PIN_TRS_0_TIP ] = _CONFIG_DFLT_IO_POLARITY_TRS_0_TIP;
config->io_type[ IO_PIN_TRS_0_RING ] = _CONFIG_DFLT_IO_TYPE_TRS_0_RING;
config->io_polarity[ IO_PIN_TRS_0_RING ] = _CONFIG_DFLT_IO_POLARITY_TRS_0_RING;
config->io_type[ IO_PIN_TRS_1_TIP ] = _CONFIG_DFLT_IO_TYPE_TRS_1_TIP;
config->io_polarity[ IO_PIN_TRS_1_TIP ] = _CONFIG_DFLT_IO_POLARITY_TRS_1_TIP;
config->io_type[ IO_PIN_TRS_1_RING ] = _CONFIG_DFLT_IO_TYPE_TRS_1_RING;
config->io_polarity[ IO_PIN_TRS_1_RING ] = _CONFIG_DFLT_IO_POLARITY_TRS_1_RING;
config->io_type[ IO_PIN_TRS_2_TIP ] = _CONFIG_DFLT_IO_TYPE_TRS_2_TIP;
config->io_polarity[ IO_PIN_TRS_2_TIP ] = _CONFIG_DFLT_IO_POLARITY_TRS_2_TIP;
config->io_type[ IO_PIN_TRS_2_RING ] = _CONFIG_DFLT_IO_TYPE_TRS_2_RING;
config->io_polarity[ IO_PIN_TRS_2_RING ] = _CONFIG_DFLT_IO_POLARITY_TRS_2_RING;
config->io_type[ IO_PIN_TRS_3_TIP ] = _CONFIG_DFLT_IO_TYPE_TRS_3_TIP;
config->io_polarity[ IO_PIN_TRS_3_TIP ] = _CONFIG_DFLT_IO_POLARITY_TRS_3_TIP;
config->io_type[ IO_PIN_TRS_3_RING ] = _CONFIG_DFLT_IO_TYPE_TRS_3_RING;
config->io_polarity[ IO_PIN_TRS_3_RING ] = _CONFIG_DFLT_IO_POLARITY_TRS_3_RING;

// Keyer configuration
config->keyer_paddle_mode = _CONFIG_DFLT_KEYER_PADDLE_MODE;
config->keyer_paddle_invert = _CONFIG_DFLT_KEYER_PADDLE_INVERT;
config->keyer_output_active_low = _CONFIG_DFLT_KEYER_OUTPUT_ACTIVE_LOW;

// Ensure we generated a valid configuration
assert_always( validate_config( config ) );
Expand Down
13 changes: 5 additions & 8 deletions src/main/application/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <stdint.h>

#include "application/buzzer.h"
#include "application/input.h"
#include "application/io.h"
#include "application/keyer.h"
#include "application/led.h"
#include "application/wpm.h"
Expand Down Expand Up @@ -44,21 +44,18 @@ typedef struct
/** If set to `false`, the LED will be disabled and will not illuminate. */
bool led_enabled[ LED_COUNT ];

/** The configured input type for each input pin. */
input_type_t input_type[ INPUT_PIN_COUNT ];
/** The configured I/O type for each I/O pin. */
io_type_t io_type[ IO_PIN_COUNT ];

/** The configured input polarity for each input pin. */
input_polarity_t input_polarity[ INPUT_PIN_COUNT ];
/** The configured I/O polarity for each I/O pin. */
io_polarity_t io_polarity[ IO_PIN_COUNT ];

/** The keyer's paddle mode. */
keyer_paddle_mode_t keyer_paddle_mode;

/** If set to `true`, the keyer will emit dashes from the left paddle and dots from the right paddle. */
bool keyer_paddle_invert;

/** If set to `true`, the keyer's output is active low. */
bool keyer_output_active_low;

} config_t;

/**
Expand Down
Loading