Skip to content

Commit

Permalink
comments, clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
stuffmatic committed Mar 25, 2023
1 parent 1a0aaa8 commit 9b66125
Show file tree
Hide file tree
Showing 13 changed files with 868 additions and 844 deletions.
88 changes: 88 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# SPDX-License-Identifier: Apache-2.0
#
# Note: The list of ForEachMacros can be obtained using:
#
# git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \
# | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \
# | sort | uniq
#
# References:
# - https://clang.llvm.org/docs/ClangFormatStyleOptions.html

---
BasedOnStyle: LLVM
AlignConsecutiveMacros: AcrossComments
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AttributeMacros:
- __aligned
- __deprecated
- __packed
- __printf_like
- __syscall
- __subsystem
BitFieldColonSpacing: After
BreakBeforeBraces: Linux
ColumnLimit: 100
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
ForEachMacros:
- 'FOR_EACH'
- 'FOR_EACH_FIXED_ARG'
- 'FOR_EACH_IDX'
- 'FOR_EACH_IDX_FIXED_ARG'
- 'FOR_EACH_NONEMPTY_TERM'
- 'RB_FOR_EACH'
- 'RB_FOR_EACH_CONTAINER'
- 'SYS_DLIST_FOR_EACH_CONTAINER'
- 'SYS_DLIST_FOR_EACH_CONTAINER_SAFE'
- 'SYS_DLIST_FOR_EACH_NODE'
- 'SYS_DLIST_FOR_EACH_NODE_SAFE'
- 'SYS_SFLIST_FOR_EACH_CONTAINER'
- 'SYS_SFLIST_FOR_EACH_CONTAINER_SAFE'
- 'SYS_SFLIST_FOR_EACH_NODE'
- 'SYS_SFLIST_FOR_EACH_NODE_SAFE'
- 'SYS_SLIST_FOR_EACH_CONTAINER'
- 'SYS_SLIST_FOR_EACH_CONTAINER_SAFE'
- 'SYS_SLIST_FOR_EACH_NODE'
- 'SYS_SLIST_FOR_EACH_NODE_SAFE'
- '_WAIT_Q_FOR_EACH'
- 'Z_FOR_EACH'
- 'Z_FOR_EACH_ENGINE'
- 'Z_FOR_EACH_EXEC'
- 'Z_FOR_EACH_FIXED_ARG'
- 'Z_FOR_EACH_FIXED_ARG_EXEC'
- 'Z_FOR_EACH_IDX'
- 'Z_FOR_EACH_IDX_EXEC'
- 'Z_FOR_EACH_IDX_FIXED_ARG'
- 'Z_FOR_EACH_IDX_FIXED_ARG_EXEC'
- 'Z_GENLIST_FOR_EACH_CONTAINER'
- 'Z_GENLIST_FOR_EACH_CONTAINER_SAFE'
- 'Z_GENLIST_FOR_EACH_NODE'
- 'Z_GENLIST_FOR_EACH_NODE_SAFE'
IfMacros:
- 'CHECKIF'
# Disabled for now, see bug https://github.com/zephyrproject-rtos/zephyr/issues/48520
#IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^".*\.h"$'
Priority: 0
- Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|limits|locale|math|setjmp|signal|stdarg|stdbool|stddef|stdint|stdio|stdlib|string|tgmath|time|wchar|wctype)\.h>$'
Priority: 1
- Regex: '^\<zephyr/.*\.h\>$'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: false
IndentWidth: 8
InsertBraces: true
SpaceBeforeParens: ControlStatementsExceptControlMacros
SortIncludes: Never
UseTab: Always
WhitespaceSensitiveMacros:
- STRINGIFY
- Z_STRINGIFY
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"type": "cppbuild",
"label": "Build unit tests",
"command": "/usr/bin/gcc",
"command": "gcc",
"args": [
"-fdiagnostics-color=always",
"-g",
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
* disconnect API?
* select/dpend on BT_* config vars
* don't use softdevice?
* fix stack overflow when receiving (sysex) events. probably related to printk. use work queue/ringbuffer to receive safely
* fix stack overflow when receiving (sysex) events. probably related to printk. use work queue/ringbuffer to process data safely in the sample app
* mention that batch tx requires softdevice
* use dedicated work queue internally?
* remove inSysexMessage from writer

# ble stuff

Expand Down
5 changes: 3 additions & 2 deletions ble_midi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ config BLE_MIDI
if BLE_MIDI

config BLE_MIDI_SEND_RUNNING_STATUS
bool ""
bool "Enable running status for transmitted MIDI messages"
default y

config BLE_MIDI_SEND_NOTE_OFF_AS_NOTE_ON
bool ""
bool "Represent note off messages as note on with zero velocity. Increases running status efficiency."
default y

config BLE_MIDI_NRF_BATCH_TX
depends on RING_BUFFER
bool ""
default n

Expand Down
38 changes: 28 additions & 10 deletions ble_midi/include/ble_midi/ble_midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

#include <zephyr/bluetooth/uuid.h>

#define BLE_MIDI_SERVICE_UUID \
BT_UUID_128_ENCODE(0x03B80E5A, 0xEDE8, 0x4B33, 0xA751, 0x6CE34EC4C700)
#define BLE_MIDI_CHAR_UUID \
BT_UUID_128_ENCODE(0x7772E5DB, 0x3868, 0x4112, 0xA1A9, 0xF2669D106BF3)
/** UUID of the BLE MIDI service */
#define BLE_MIDI_SERVICE_UUID BT_UUID_128_ENCODE(0x03B80E5A, 0xEDE8, 0x4B33, 0xA751, 0x6CE34EC4C700)
/** UUID of the MIDI data I/O characteristic */
#define BLE_MIDI_CHAR_UUID BT_UUID_128_ENCODE(0x7772E5DB, 0x3868, 0x4112, 0xA1A9, 0xF2669D106BF3)

typedef void (*ble_midi_tx_available_cb_t)();
/** Called when the BLE MIDI service becomes available/unavailable. */
typedef void (*ble_midi_available_cb_t)(uint32_t is_available);
/** Called when a BLE MIDI packet has just been sent. */
typedef void (*ble_midi_tx_available_cb_t)();
/** Called when a non-sysex message has been parsed */
typedef void (*ble_midi_message_cb_t)(uint8_t *bytes, uint8_t num_bytes, uint16_t timestamp);
/** Called when a sysex message starts */
Expand All @@ -20,8 +22,7 @@ typedef void (*ble_midi_sysex_data_cb_t)(uint8_t data_byte);
typedef void (*ble_midi_sysex_end_cb_t)(uint16_t timestamp);

/** Callbacks set to NULL are ignored. */
struct ble_midi_callbacks
{
struct ble_midi_callbacks {
ble_midi_available_cb_t available_cb;
ble_midi_tx_available_cb_t tx_available_cb;
ble_midi_message_cb_t midi_message_cb;
Expand All @@ -31,18 +32,35 @@ struct ble_midi_callbacks
};

/**
* Call once.
* Initializes the BLE MIDI service. This should only be called once.
*/
void ble_midi_init(struct ble_midi_callbacks *callbacks);

/**
/**
* Sends a non-sysex MIDI message.
* @param bytes A buffer of length 3 containing the message bytes to send.
* @param bytes A zero padded buffer of length 3 containing the message bytes to send.
* @return 0 on success or a non-zero number on failure.
*/
int ble_midi_tx_msg(uint8_t *bytes);

/**
* Start transmission of a sysex message.
* @return 0 on success or a non-zero number on failure.
*/
int ble_midi_tx_sysex_start();

/**
* Transmit sysex data bytes.
* @param bytes The data bytes to send. Must have the high bit set to 0.
* @param num_bytes The number of data bytes to send.
* @return On success, the number of bytes written. A negative number on error.
*/
int ble_midi_tx_sysex_data(uint8_t *bytes, int num_bytes);

/**
* End transmission of a sysex message.
* @return 0 on success or a non-zero number on failure.
*/
int ble_midi_tx_sysex_end();

#endif
Loading

0 comments on commit 9b66125

Please sign in to comment.