diff --git a/.gitignore b/.gitignore index 19caf45..3e6b1e3 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,123 @@ esp-idf dependencies.lock cmake-build-debug/ cmake-build-debug-esp-idf/ +cmake-build-debug-esp-idf*/ +font.txt + +# Created by https://www.toptal.com/developers/gitignore/api/clion +# Edit at https://www.toptal.com/developers/gitignore?templates=clion + +### CLion ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### CLion Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +# End of https://www.toptal.com/developers/gitignore/api/clion diff --git a/.gitmodules b/.gitmodules index 2f25486..5968218 100644 --- a/.gitmodules +++ b/.gitmodules @@ -30,21 +30,24 @@ path = components/eeprom url = https://github.com/Nicolai-Electronics/esp32-component-i2c-eeprom.git branch = main -[submodule "components/troopers23-bsp"] - path = components/troopers23-bsp - url = git@github.com:badgeteam/esp32-component-troopers23-bsp.git +[submodule "components/troopers24-bsp"] + path = components/troopers24-bsp + url = git@github.com:badgeteam/troopers24-bsp.git [submodule "components/i2c-pca9555"] path = components/i2c-pca9555 url = git@github.com:badgeteam/esp32-component-pca9555.git [submodule "components/keyboard"] path = components/keyboard - url = git@github.com:badgeteam/troopers2023-keyboard.git -[submodule "components/troopers23-efuse"] - path = components/troopers23-efuse - url = git@github.com:badgeteam/troopers23-efuse.git + url = git@github.com:badgeteam/troopers24-keyboard.git +[submodule "components/troopers24-efuse"] + path = components/troopers24-efuse + url = git@github.com:badgeteam/troopers24-efuse.git [submodule "components/i2c-controller"] path = components/i2c-controller url = git@github.com:hnzlmnn/esp32-component-controller.git [submodule "components/i2c-ktd2052"] path = components/i2c-ktd2052 url = git@github.com:hnzlmnn/esp32-component-ktd2052.git +[submodule "components/pax-keyboard"] + path = components/pax-keyboard + url = https://github.com/robotman2412/pax-keyboard.git diff --git a/.idea/misc.xml b/.idea/misc.xml index 79b3c94..c76f782 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,7 @@ + + \ No newline at end of file diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..78c9a28 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.9.12 diff --git a/components/appfs b/components/appfs index 4125e8e..a0849db 160000 --- a/components/appfs +++ b/components/appfs @@ -1 +1 @@ -Subproject commit 4125e8e444b5a111da4b9fdcac7f5a2468f1af5d +Subproject commit a0849db4c1b583d46794b13b7137231573e2d129 diff --git a/components/gui-toolkit/CMakeLists.txt b/components/gui-toolkit/CMakeLists.txt index 631e8ac..afc5bf2 100644 --- a/components/gui-toolkit/CMakeLists.txt +++ b/components/gui-toolkit/CMakeLists.txt @@ -7,7 +7,7 @@ idf_component_register( REQUIRES "pax-graphics" "pax-codecs" - "physical-keyboard" + "pax-keyboard" "spi-ili9341" - "troopers23-bsp" + "troopers24-bsp" ) diff --git a/components/gui-toolkit/graphics_wrapper.c b/components/gui-toolkit/graphics_wrapper.c index fec6c2a..fd2194c 100644 --- a/components/gui-toolkit/graphics_wrapper.c +++ b/components/gui-toolkit/graphics_wrapper.c @@ -2,8 +2,11 @@ #include +#include "esp_log.h" #include "hardware.h" -#include "physical_keyboard.h" +#include "pax_keyboard.h" + +static const char* TAG = "graphic_wrapper"; void render_outline(float position_x, float position_y, float width, float height, pax_col_t border_color, pax_col_t background_color) { pax_buf_t* pax_buffer = get_pax_buffer(); @@ -29,54 +32,6 @@ void render_message(char* message) { pax_noclip(pax_buffer); } -int buttonToKey(uint8_t button) { - switch (button) { - case BUTTON_ACCEPT: return PKB_ACCEPT; - case BUTTON_BACK: return -1; - case BUTTON_START: return PKB_NO_INPUT; - case BUTTON_SELECT: return PKB_NO_INPUT; - case JOYSTICK_UP: return PKB_UP; - case JOYSTICK_DOWN: return PKB_DOWN; - case JOYSTICK_LEFT: return PKB_LEFT; - case JOYSTICK_RIGHT: return PKB_RIGHT; - case KEY_SHIELD: return PKB_SUPER; - case KEY_FN: return PKB_FN; - case KEY_SPACE: return PKB_SPACE; - case KEY_BACKSPACE: return PKB_DELETE_BEFORE; - case KEY_SHIFT: return PKB_SHIFT; - case KEY_RETURN: return PKB_RETURN; - case KEY_Q: return PKB_Q; - case KEY_W: return PKB_W; - case KEY_E: return PKB_E; - case KEY_R: return PKB_R; - case KEY_T: return PKB_T; - case KEY_Y: return PKB_Y; - case KEY_U: return PKB_U; - case KEY_I: return PKB_I; - case KEY_O: return PKB_O; - case KEY_P: return PKB_P; - case KEY_A: return PKB_A; - case KEY_S: return PKB_S; - case KEY_D: return PKB_D; - case KEY_F: return PKB_F; - case KEY_G: return PKB_G; - case KEY_H: return PKB_H; - case KEY_J: return PKB_J; - case KEY_K: return PKB_K; - case KEY_L: return PKB_L; - case KEY_Z: return PKB_Z; - case KEY_X: return PKB_X; - case KEY_C: return PKB_C; - case KEY_V: return PKB_V; - case KEY_B: return PKB_B; - case KEY_N: return PKB_N; - case KEY_M: return PKB_M; - default: - printf("Unmapped key: %u\n", button); - break; - } - return PKB_NO_INPUT; -} bool keyboard(xQueueHandle buttonQueue, float aPosX, float aPosY, float aWidth, float aHeight, const char* aTitle, const char* aHint, char* aOutput, size_t aOutputSize) { @@ -129,17 +84,65 @@ bool keyboard(xQueueHandle buttonQueue, float aPosX, float aPosY, float aWidth, if (xQueueReceive(buttonQueue, &buttonMessage, portMAX_DELAY) == pdTRUE) { uint8_t button = buttonMessage.input; bool value = buttonMessage.state; - int key = buttonToKey(button); - if (key == -1) { - if (value) { - running = false; - } - } else if (key != PKB_NO_INPUT) { - if (value) { - pkb_press(&kb_ctx, key); - } else { - pkb_release(&kb_ctx, key); - } + + switch (button) { + case JOYSTICK_DOWN: + if (value) { + pkb_press(&kb_ctx, PKB_DOWN); + } else { + pkb_release(&kb_ctx, PKB_DOWN); + } + break; + case JOYSTICK_UP: + if (value) { + pkb_press(&kb_ctx, PKB_UP); + } else { + pkb_release(&kb_ctx, PKB_UP); + } + break; + case JOYSTICK_LEFT: + if (value) { + pkb_press(&kb_ctx, PKB_LEFT); + } else { + pkb_release(&kb_ctx, PKB_LEFT); + } + break; + case JOYSTICK_RIGHT: + if (value) { + pkb_press(&kb_ctx, PKB_RIGHT); + } else { + pkb_release(&kb_ctx, PKB_RIGHT); + } + break; + case BUTTON_ACCEPT: + if (value) { + pkb_press(&kb_ctx, PKB_CHARSELECT); + } else { + pkb_release(&kb_ctx, PKB_CHARSELECT); + } + break; + case BUTTON_BACK: + if (value) { + pkb_press(&kb_ctx, PKB_DELETE_BEFORE); + } else { + pkb_release(&kb_ctx, PKB_DELETE_BEFORE); + } + break; + case BUTTON_SELECT: + if (value) { + pkb_press(&kb_ctx, PKB_MODESELECT); + } else { + pkb_release(&kb_ctx, PKB_MODESELECT); + } + break; + case BUTTON_START: + if (value) { + running = false; + } + break; + default: + + break; } } pkb_loop(&kb_ctx); diff --git a/components/keyboard b/components/keyboard index 2fb79c4..e8d659a 160000 --- a/components/keyboard +++ b/components/keyboard @@ -1 +1 @@ -Subproject commit 2fb79c4635b32bf9b0327e7eb0cf3007d9d07477 +Subproject commit e8d659ac5c0f9bd95fb5a0323e993430c18f904e diff --git a/components/pax-keyboard b/components/pax-keyboard new file mode 160000 index 0000000..78f781d --- /dev/null +++ b/components/pax-keyboard @@ -0,0 +1 @@ +Subproject commit 78f781d0316a66ef35bb4d3cac03751ee3072d77 diff --git a/components/physical-keyboard/CMakeLists.txt b/components/physical-keyboard/CMakeLists.txt deleted file mode 100644 index 2f83168..0000000 --- a/components/physical-keyboard/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -idf_component_register( - SRCS - "physical_keyboard.c" - INCLUDE_DIRS - "." - REQUIRES - "pax-graphics" -) diff --git a/components/physical-keyboard/physical_keyboard.c b/components/physical-keyboard/physical_keyboard.c deleted file mode 100644 index 9a508b9..0000000 --- a/components/physical-keyboard/physical_keyboard.c +++ /dev/null @@ -1,465 +0,0 @@ -/* - MIT License - - Copyright (c) 2023 Renze Nicolai - Copyright (c) 2022 Julian Scheffers - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#include -#include -#include -#include - -/* ==== Miscellaneous ==== */ - -// Initialise the context with default settings. -void pkb_init(pax_buf_t *buf, pkb_ctx_t *ctx, size_t buffer_cap) { - // Allocate a bufffer. - char *buffer = malloc(buffer_cap); - memset(buffer, 0, buffer_cap); - - // Some defaults. - *ctx = (pkb_ctx_t) { - // Position on screen of the keyboard. - .x = 0, - .y = 0, - // Maximum size of the keyboard. - .width = buf->width, - .height = buf->height, - - // Content of the keyboard. - .content = buffer, - // Size in bytes of capacity of the content buffer. - .content_cap = buffer_cap, - - // Starting position of the selection in the text box. - .selection = 0, - // Cursor position of the text box. - .cursor = 0, - - // Cursor position of the keyboard. - .key_x = 3, - .key_y = 1, - // The currently held input. - .held = PKB_NO_INPUT, - // The time that holding the input started. - .hold_start = 0, - // The last time pkb_press was called. - .last_press = 0, - - // Whether the keyboard is multi-line. - .multiline = false, - // Whether the keyboard is in insert mode. - .insert = false, - // The board that is currently selected. - .board_sel = PKB_LOWERCASE, - - // The font to use for the keyboard. - .kb_font = PAX_FONT_DEFAULT, - // The font size to use for the keyboard. - .kb_font_size = 27, - // The font to use for the text. - .text_font = PAX_FONT_DEFAULT, - // The font size to use for the text. - .text_font_size = 18, - // The text color to use. - .text_col = 0xffffffff, - // The text color to use when a character is being held down. - .sel_text_col = 0xff000000, - // The selection color to use. - .sel_col = 0xff007fff, - // The background color to use. - .bg_col = 0xff000000, - - // Whether something has changed since last draw. - .dirty = true, - // Whether the text has changed since last draw. - .text_dirty = true, - // Whether the keyboard has changed since last draw. - .kb_dirty = true, - // Whether just the selected character has changed since last draw. - .sel_dirty = true, - // Previous cursor position of the keyboard. - // Used for sel_dirty. - .last_key_x = 3, - .last_key_y = 1, - - // Indicates that the input has been accepted. - .input_accepted = false, - }; - - // TODO: Pick fancier text sizes. -} - -// Free any memory associated with the context. -void pkb_destroy(pkb_ctx_t *ctx) { - free(ctx->content); - ctx->content = NULL; - ctx->content_cap = 0; -} - - -// Replaces the text in the keyboard with the given text. -// Makes a copy of the given text. -void pkb_set_content(pkb_ctx_t *ctx, const char *content) { - // Replace the content. - strncpy(ctx->content, content, ctx->content_cap - 1); - ctx->content[ctx->content_cap-1] = 0; - ctx->cursor = strlen(content); -} - -// Draw just the board part. -static void pkb_render_keyb(pax_buf_t *buf, pkb_ctx_t *ctx, bool do_bg) { - // Draw background. - if (do_bg) { - pax_draw_rect(buf, ctx->bg_col, ctx->x, ctx->y + ctx->height - ctx->kb_font_size*4, ctx->width, ctx->kb_font_size*4); - } -} - -// Draw just the text part. -static void pkb_render_text(pax_buf_t *buf, pkb_ctx_t *ctx, bool do_bg) { - // Draw background. - if (do_bg) { - pax_draw_rect(buf, ctx->bg_col, ctx->x-0.01, ctx->y-0.01, ctx->width+0.02, ctx->height - ctx->kb_font_size*4 + 0.02); - } - if (ctx->key_y == -1) { - // Outline us. - pax_outline_rect(buf, ctx->sel_col, ctx->x, ctx->y, ctx->width - 1, ctx->height - ctx->kb_font_size*4 - 1); - } - - // Some setup. - float x = ctx->x + 2; - float y = ctx->y + 2; - char tmp[2] = {0, 0}; - int cursor_line = 0; - - // Draw everything. - for (int i = 0; i < strlen(ctx->content); i++) { - if (ctx->cursor == i) { - // The cursor in between the input. - pax_draw_line(buf, ctx->sel_col, x, y, x, y + ctx->text_font_size - 1); - } - - // The character of the input. - tmp[0] = ctx->content[i]; - pax_vec1_t dims = pax_text_size(ctx->text_font, ctx->text_font_size, tmp); - - if (tmp[0] == '\n') { - y += dims.y/2; - x = ctx->x + 2; - continue; - } - - if (x + dims.x > ctx->width - 2) { - // Word wrap. - x = ctx->x + 2; - y += ctx->text_font_size; - } - pax_draw_text(buf, ctx->text_col, ctx->text_font, ctx->text_font_size, x, y, tmp); - x += dims.x; - } - if (ctx->cursor == strlen(ctx->content)) { - // The cursor after the input. - pax_draw_line(buf, ctx->sel_col, x, y, x, y + ctx->text_font_size - 1); - } -} - -// Draw one specific key. -static void pkb_render_key(pax_buf_t *buf, pkb_ctx_t *ctx, int key_x, int key_y) { - if (key_y == -1) { - // If key_y is -1, the text box is selected to render. - pkb_render_text(buf, ctx, true); - return; - } -} - -// Redraw the complete on-screen keyboard. -void pkb_render(pax_buf_t *buf, pkb_ctx_t *ctx) { - if (matrix_2d_is_identity(buf->stack_2d.value) - && ctx->x == 0 && ctx->y == 0 - && ctx->width == buf->width - && ctx->height == buf->height) { - // We can just fill the entire screen. - pax_background(buf, ctx->bg_col); - } else { - // We'll need to fill a rectangle. - pax_draw_rect( - buf, ctx->bg_col, - ctx->x, ctx->y, - ctx->width, ctx->height - ); - } - - // Draw the board. - pkb_render_keyb(buf, ctx, false); - // Time to draw some text. - pkb_render_text(buf, ctx, false); - - // Mark as not dirty. - ctx->dirty = false; - ctx->kb_dirty = false; - ctx->sel_dirty = false; - ctx->text_dirty = false; - ctx->last_key_x = ctx->key_x; - ctx->last_key_y = ctx->key_y; -} - -// Redraw only the changed parts of the on-screen keyboard. -void pkb_redraw(pax_buf_t *buf, pkb_ctx_t *ctx) { - if (ctx->text_dirty) { - pkb_render_text(buf, ctx, true); - } - if (ctx->kb_dirty) { - pkb_render_keyb(buf, ctx, true); - } else if (ctx->sel_dirty) { - pkb_render_key(buf, ctx, ctx->last_key_x, ctx->last_key_y); - pkb_render_key(buf, ctx, ctx->key_x, ctx->key_y); - } - - // Mark as not dirty. - ctx->dirty = false; - ctx->kb_dirty = false; - ctx->sel_dirty = false; - ctx->text_dirty = false; - ctx->last_key_x = ctx->key_x; - ctx->last_key_y = ctx->key_y; -} - -/* ==== Text editing ==== */ - -// Handling of delete or backspace. -static void pkb_delete(pkb_ctx_t *ctx, bool is_backspace) { - size_t oldlen = strlen(ctx->content); - if (!is_backspace && ctx->cursor == oldlen) { - // No forward deleting at the end of the line. - return; - } else if (is_backspace && ctx->cursor == 0) { - // No backward deleting at the start of the line. - return; - } else if (!is_backspace) { - // Advanced backspace. - ctx->cursor ++; - } - - // Copy back everything including null terminator. - ctx->cursor --; - for (int i = ctx->cursor; i < oldlen; i++) { - ctx->content[i] = ctx->content[i+1]; - } - - ctx->text_dirty = true; -} - -// Handling of normal input. -static void pkb_append(pkb_ctx_t *ctx, char value) { - size_t oldlen = strlen(ctx->content); - if (oldlen + 2 >= ctx->content_cap) { - // That's too big. - return; - } - - // Copy over the remainder of the buffer. - // If there's no text this still copies the null terminator. - for (int i = oldlen; i >= ctx->cursor; i --) { - ctx->content[i + 1] = ctx->content[i]; - } - - // And finally insert at the character. - ctx->content[ctx->cursor] = value; - ctx->cursor ++; - ctx->text_dirty = true; -} - -/* ==== Input handling ==== */ - -// The loop that allows input repeating. -void pkb_loop(pkb_ctx_t *ctx) { - int64_t now = esp_timer_get_time(); - if (!ctx->held) return; - bool is_dir = (ctx->held >= PKB_UP) && (ctx->held <= PKB_RIGHT); - - if ((ctx->hold_start + 1000000 < now) || (is_dir && ctx->hold_start + 250000 < now)) { - // 8 repeats per second. - if (ctx->last_press + 125000 < now) { - pkb_press(ctx, ctx->held); - } - } -} - -const char uppercase_board[] = "QWERTYUIOPASDFGHJKLZXCVBNM"; -const char lowercase_board[] = "qwertyuiopasdfghjklzxcvbnm"; -const char number_board[] = "1234567890....;'[]\\..-=,./"; -const char symbols_board[] = "!@#$%^&*()....:\"{}|.?—+<>?"; - -const char* boards[] = { - lowercase_board, - uppercase_board, - number_board, - symbols_board, -}; - -// A pressing of the input. -void pkb_press(pkb_ctx_t *ctx, pkb_input_t input) { - ctx->last_press = esp_timer_get_time(); - switch (input) { - case PKB_ACCEPT: - ctx->input_accepted = true; - break; - case PKB_SHIFT: - ctx->board_sel = PBK_UPPERCASE; - break; - case PKB_SUPER: - ctx->board_sel = PKB_NUMBERS; - break; - case PKB_FN: - ctx->board_sel = PKB_SYMBOLS; - break; - case PKB_Q: - pkb_append(ctx, boards[ctx->board_sel][0]); - break; - case PKB_W: - pkb_append(ctx, boards[ctx->board_sel][1]); - break; - case PKB_E: - pkb_append(ctx, boards[ctx->board_sel][2]); - break; - case PKB_R: - pkb_append(ctx, boards[ctx->board_sel][3]); - break; - case PKB_T: - pkb_append(ctx, boards[ctx->board_sel][4]); - break; - case PKB_Y: - pkb_append(ctx, boards[ctx->board_sel][5]); - break; - case PKB_U: - pkb_append(ctx, boards[ctx->board_sel][6]); - break; - case PKB_I: - pkb_append(ctx, boards[ctx->board_sel][7]); - break; - case PKB_O: - pkb_append(ctx, boards[ctx->board_sel][8]); - break; - case PKB_P: - pkb_append(ctx, boards[ctx->board_sel][9]); - break; - case PKB_A: - pkb_append(ctx, boards[ctx->board_sel][10]); - break; - case PKB_S: - pkb_append(ctx, boards[ctx->board_sel][11]); - break; - case PKB_D: - pkb_append(ctx, boards[ctx->board_sel][12]); - break; - case PKB_F: - pkb_append(ctx, boards[ctx->board_sel][13]); - break; - case PKB_G: - pkb_append(ctx, boards[ctx->board_sel][14]); - break; - case PKB_H: - pkb_append(ctx, boards[ctx->board_sel][15]); - break; - case PKB_J: - pkb_append(ctx, boards[ctx->board_sel][16]); - break; - case PKB_K: - pkb_append(ctx, boards[ctx->board_sel][17]); - break; - case PKB_L: - pkb_append(ctx, boards[ctx->board_sel][18]); - break; - case PKB_Z: - pkb_append(ctx, boards[ctx->board_sel][19]); - break; - case PKB_X: - pkb_append(ctx, boards[ctx->board_sel][20]); - break; - case PKB_C: - pkb_append(ctx, boards[ctx->board_sel][21]); - break; - case PKB_V: - pkb_append(ctx, boards[ctx->board_sel][22]); - break; - case PKB_B: - pkb_append(ctx, boards[ctx->board_sel][23]); - break; - case PKB_N: - pkb_append(ctx, boards[ctx->board_sel][24]); - break; - case PKB_M: - pkb_append(ctx, boards[ctx->board_sel][25]); - break; - case PKB_SPACE: - pkb_append(ctx, ' '); - break; - case PKB_DELETE_BEFORE: - pkb_delete(ctx, true); - break; - case PKB_DELETE_AFTER: - pkb_delete(ctx, false); - break; - case PKB_RETURN: - pkb_append(ctx, '\n'); - break; - case PKB_LEFT: - if (ctx->cursor < strlen(ctx->content)) { - ctx->cursor++; - } - break; - case PKB_RIGHT: - if (ctx->cursor > 0) { - ctx->cursor--; - } - break; - default: - break; - } - if (input != PKB_SHIFT && input != ctx->held) { - ctx->held = input; - ctx->hold_start = esp_timer_get_time(); - } - ctx->dirty = true; -} - -// A relealing of the input. -void pkb_release(pkb_ctx_t *ctx, pkb_input_t input) { - switch (input) { - // Shift key, the releasening. - case PKB_SHIFT: - ctx->board_sel = PKB_LOWERCASE; - break; - case PKB_SUPER: - ctx->board_sel = PKB_LOWERCASE; - break; - case PKB_FN: - ctx->board_sel = PKB_LOWERCASE; - break; - default: - break; - } - if (ctx->held == input) { - ctx->held = PKB_NO_INPUT; - ctx->dirty = true; - } -} diff --git a/components/physical-keyboard/physical_keyboard.h b/components/physical-keyboard/physical_keyboard.h deleted file mode 100644 index 961aa47..0000000 --- a/components/physical-keyboard/physical_keyboard.h +++ /dev/null @@ -1,155 +0,0 @@ -#pragma once - -#include -#include -#include - -// A number of inputs supported by the PAX keyboard. -typedef enum { - // Represents no input being pressed. - PKB_NO_INPUT, - // Movement of the cursor. - PKB_UP, PKB_DOWN, PKB_LEFT, PKB_RIGHT, - // Delete to the left or the selection. Backspace key. - PKB_DELETE_BEFORE, - // Delete to the right or the selection. Delete key. - PKB_DELETE_AFTER, - // Switch between lower case, upper case and symbols. - PKB_MODESELECT, - // Enter a character. - PKB_CHARSELECT, - // The same thing as the shift key. - // Goes between PKB_LOWERCASE and PKB_UPPERCASE or PKB_NUMBERS and PKB_SYMBOLS. - PKB_SHIFT, - PKB_ENTER, - PKB_ACCEPT, - PKB_SUPER, - PKB_FN, - PKB_Q, - PKB_W, - PKB_E, - PKB_R, - PKB_T, - PKB_Y, - PKB_U, - PKB_I, - PKB_O, - PKB_P, - PKB_A, - PKB_S, - PKB_D, - PKB_F, - PKB_G, - PKB_H, - PKB_J, - PKB_K, - PKB_L, - PKB_Z, - PKB_X, - PKB_C, - PKB_V, - PKB_B, - PKB_N, - PKB_M, - PKB_SPACE, - PKB_RETURN -} pkb_input_t; - -// The type of keyboard currently selected. -typedef enum { - // Lowercase and ., - PKB_LOWERCASE, - // Uppercase and <> - PBK_UPPERCASE, - // Numbers and symbols 1/2 - PKB_NUMBERS, - // Symbols 2/2 - PKB_SYMBOLS, -} pkb_keyboard_t; - -// The PAX keyboard context used for drawing and alike. -typedef struct { - // Position on screen of the keyboard. - int x, y; - // Maximum size of the keyboard. - int width, height; - - // Content of the keyboard. - char *content; - // Size in bytes of capacity of the content buffer. - size_t content_cap; - - // Starting position of the selection in the text box. - int selection; - // Cursor position of the text box. - int cursor; - - // Cursor position of the keyboard. - int key_x, key_y; - // The currently held input. - pkb_input_t held; - // The time that holding the input started. - int64_t hold_start; - // The last time pkb_press was called. - int64_t last_press; - - // Whether the keyboard is multi-line. - bool multiline; - // Whether the keyboard is in insert mode. - bool insert; - // The board that is currently selected. - pkb_keyboard_t board_sel; - - // The font to use for the keyboard. - const pax_font_t *kb_font; - // The font size to use for the keyboard. - float kb_font_size; - // The font to use for the text. - const pax_font_t *text_font; - // The font size to use for the text. - float text_font_size; - // The text color to use. - pax_col_t text_col; - // The text color to use when a character is being held down. - pax_col_t sel_text_col; - // The selection color to use. - pax_col_t sel_col; - // The background color to use. - pax_col_t bg_col; - - // Whether something has changed since last draw. - bool dirty; - // Whether the text has changed since last draw. - bool text_dirty; - // Whether the keyboard has changed since last draw. - bool kb_dirty; - // Whether just the selected character has changed since last draw. - bool sel_dirty; - // Previous cursor position of the keyboard. - // Used for sel_dirty. - int last_key_x, last_key_y; - - // Indicates that the input has been accepted. - bool input_accepted; -} pkb_ctx_t; - -// Initialise the context with default settings. -void pkb_init (pax_buf_t *buf, pkb_ctx_t *ctx, size_t buffer_cap); -// Free any memory associated with the context. -void pkb_destroy(pkb_ctx_t *ctx); -// Replaces the text in the keyboard with the given text. -// Makes a copy of the given text. -void pkb_set_content(pkb_ctx_t *ctx, const char *content); - -// Redraw the complete on-screen keyboard. -void pkb_render (pax_buf_t *buf, pkb_ctx_t *ctx); -// Redraw only the changed parts of the on-screen keyboard. -void pkb_redraw (pax_buf_t *buf, pkb_ctx_t *ctx); - -// The loop that allows input repeating. -void pkb_loop (pkb_ctx_t *ctx); - -// A pressing of the input. -void pkb_press (pkb_ctx_t *ctx, pkb_input_t input); -// A relealing of the input. -void pkb_release(pkb_ctx_t *ctx, pkb_input_t input); diff --git a/components/spi-cc1200/CMakeLists.txt b/components/spi-cc1200/CMakeLists.txt deleted file mode 100644 index d3aea8a..0000000 --- a/components/spi-cc1200/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -idf_component_register( - SRCS "cc1200.c" - "cc1200_hal.c" - "cc1200_spi.c" - "cc1200_statemachine.c" - "cc1200-868-fsk-1-2kbps.c" - "cc1200-802154g-863-870-fsk-50kbps.c" - "troopers.c" - INCLUDE_DIRS include - REQUIRES "mbedtls" - "nvs_flash" -) diff --git a/components/spi-cc1200/cc1200-802154g-863-870-fsk-50kbps.c b/components/spi-cc1200/cc1200-802154g-863-870-fsk-50kbps.c deleted file mode 100644 index f827a77..0000000 --- a/components/spi-cc1200/cc1200-802154g-863-870-fsk-50kbps.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2015, Weptech elektronik GmbH Germany - * http://www.weptech.de - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Ported to badge.team by Jeff Gough - */ - -#include "include/cc1200-rf-cfg.h" -#include "include/cc1200-const.h" -#include "include/contiki.h" -/* - * This is a setup for the following configuration: - * - * 802.15.4g - * ========= - * Table 68f: Frequency band identifier 4 (863-870 MHz) - * Table 68g: Modulation scheme identifier 0 (Filtered FSK) - * Table 68h: Mode #1 (50kbps) - */ - -/* Base frequency in kHz */ -#define RF_CFG_CHAN_CENTER_F0 863125 -/* Channel spacing in Hz */ -#define RF_CFG_CHAN_SPACING 200000 -/* The minimum channel */ -#define RF_CFG_MIN_CHANNEL 0 -/* The maximum channel */ -#define RF_CFG_MAX_CHANNEL 33 -/* The maximum output power in dBm */ -#define RF_CFG_MAX_TXPOWER CC1200_CONST_TX_POWER_MAX -/* The carrier sense level used for CCA in dBm */ -#define RF_CFG_CCA_THRESHOLD (-91) -/* The RSSI offset in dBm */ -#define RF_CFG_RSSI_OFFSET (-81) -/*---------------------------------------------------------------------------*/ -static const char rf_cfg_descriptor[] = "802.15.4g 863-870MHz MR-FSK mode #1"; -/*---------------------------------------------------------------------------*/ -/* - * Register settings exported from SmartRF Studio using the standard template - * "trxEB RF Settings Performance Line". - */ - -// Modulation format = 2-GFSK -// Whitening = false -// Packet length = 255 -// Packet length mode = Variable -// Packet bit length = 0 -// Symbol rate = 50 -// Deviation = 24.948120 -// Carrier frequency = 867.999878 -// Device address = 0 -// Manchester enable = false -// Address config = No address check -// Bit rate = 50 -// RX filter BW = 104.166667 - -static const registerSetting_t preferredSettings[]= -{ - {CC1200_IOCFG2, 0x06}, - {CC1200_SYNC3, 0x6E}, - {CC1200_SYNC2, 0x4E}, - {CC1200_SYNC1, 0x90}, - {CC1200_SYNC0, 0x4E}, - {CC1200_SYNC_CFG1, 0xE5}, - {CC1200_SYNC_CFG0, 0x23}, - {CC1200_DEVIATION_M, 0x47}, - {CC1200_MODCFG_DEV_E, 0x0B}, - {CC1200_DCFILT_CFG, 0x56}, - - /* - * 18.1.1.1 Preamble field - * The Preamble field shall contain phyFSKPreambleLength (as defined in 9.3) - * multiples of the 8-bit sequence “01010101” for filtered 2FSK. - * The Preamble field shall contain phyFSKPreambleLength multiples of the - * 16-bit sequence “0111 0111 0111 0111” for filtered 4FSK. - * - * We need to define this in order to be able to compute e.g. timeouts for the - * MAC layer. According to 9.3, phyFSKPreambleLength can be configured between - * 4 and 1000. We set it to 4. Attention: Once we use a long wake-up preamble, - * the timing parameters have to change accordingly. Will we use a shorter - * preamble for an ACK in this case??? - */ - {CC1200_PREAMBLE_CFG1, 0x19}, - - {CC1200_PREAMBLE_CFG0, 0xBA}, - {CC1200_IQIC, 0xC8}, - {CC1200_CHAN_BW, 0x84}, - {CC1200_MDMCFG1, 0x42}, - {CC1200_MDMCFG0, 0x05}, - {CC1200_SYMBOL_RATE2, 0x94}, - {CC1200_SYMBOL_RATE1, 0x7A}, - {CC1200_SYMBOL_RATE0, 0xE1}, - {CC1200_AGC_REF, 0x27}, - {CC1200_AGC_CS_THR, 0xF1}, - {CC1200_AGC_CFG1, 0x11}, - {CC1200_AGC_CFG0, 0x90}, - {CC1200_FIFO_CFG, 0x00}, - {CC1200_FS_CFG, 0x12}, - {CC1200_PKT_CFG2, 0x24}, - {CC1200_PKT_CFG0, 0x20}, - {CC1200_PKT_LEN, 0xFF}, - {CC1200_IF_MIX_CFG, 0x18}, - {CC1200_TOC_CFG, 0x03}, - {CC1200_MDMCFG2, 0x02}, - {CC1200_FREQ2, 0x56}, - {CC1200_FREQ1, 0xCC}, - {CC1200_FREQ0, 0xCC}, - {CC1200_IF_ADC1, 0xEE}, - {CC1200_IF_ADC0, 0x10}, - {CC1200_FS_DIG1, 0x04}, - {CC1200_FS_DIG0, 0x50}, - {CC1200_FS_CAL1, 0x40}, - {CC1200_FS_CAL0, 0x0E}, - {CC1200_FS_DIVTWO, 0x03}, - {CC1200_FS_DSM0, 0x33}, - {CC1200_FS_DVC1, 0xF7}, - {CC1200_FS_DVC0, 0x0F}, - {CC1200_FS_PFD, 0x00}, - {CC1200_FS_PRE, 0x6E}, - {CC1200_FS_REG_DIV_CML, 0x1C}, - {CC1200_FS_SPARE, 0xAC}, - {CC1200_FS_VCO0, 0xB5}, - {CC1200_IFAMP, 0x05}, - {CC1200_XOSC5, 0x0E}, - {CC1200_XOSC1, 0x03}, -}; -/*---------------------------------------------------------------------------*/ -/* Global linkage: symbol name must be different in each exported file! */ -const cc1200_rf_cfg_t cc1200_802154g_863_870_fsk_50kbps = { - .cfg_descriptor = rf_cfg_descriptor, - .register_settings = preferredSettings, - .size_of_register_settings = sizeof(preferredSettings), - .tx_pkt_lifetime = (RTIMER_SECOND / 20), - .tx_rx_turnaround = (RTIMER_SECOND / 100), - .chan_center_freq0 = RF_CFG_CHAN_CENTER_F0, - .chan_spacing = RF_CFG_CHAN_SPACING, - .min_channel = RF_CFG_MIN_CHANNEL, - .max_channel = RF_CFG_MAX_CHANNEL, - .max_txpower = RF_CFG_MAX_TXPOWER, - .cca_threshold = RF_CFG_CCA_THRESHOLD, - .rssi_offset = RF_CFG_RSSI_OFFSET, -}; -/*---------------------------------------------------------------------------*/ diff --git a/components/spi-cc1200/cc1200-868-fsk-1-2kbps.c b/components/spi-cc1200/cc1200-868-fsk-1-2kbps.c deleted file mode 100644 index e98c9da..0000000 --- a/components/spi-cc1200/cc1200-868-fsk-1-2kbps.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2015, Weptech elektronik GmbH Germany - * http://www.weptech.de - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - */ - -#include "include/cc1200-rf-cfg.h" -#include "include/cc1200-const.h" -#include "include/contiki.h" - -/* - * This is a setup for the following configuration: - * - * cc1200 at 1.2 kbps, 2-FSK, 12.5 kHz Channel Spacing (868 MHz). - */ - -/* Base frequency in kHz */ -#define RF_CFG_CHAN_CENTER_F0 867787 -/* Channel spacing in Hz */ -#define RF_CFG_CHAN_SPACING 12500 -/* The minimum channel */ -#define RF_CFG_MIN_CHANNEL 0 -/* The maximum channel */ -#define RF_CFG_MAX_CHANNEL 33 -/* The maximum output power in dBm */ -#define RF_CFG_MAX_TXPOWER CC1200_CONST_TX_POWER_MAX -/* The carrier sense level used for CCA in dBm */ -#define RF_CFG_CCA_THRESHOLD (-91) -/* The RSSI offset in dBm */ -#define RF_CFG_RSSI_OFFSET (-99) -/*---------------------------------------------------------------------------*/ -static const char rf_cfg_descriptor[] = "868MHz 2-FSK 1.2 kbps"; -/*---------------------------------------------------------------------------*/ -/* - * Register settings exported from SmartRF Studio using the standard template - * "trxEB RF Settings Performance Line". - */ - -// Modulation format = 2-FSK -// Whitening = false -// Symbol rate = 1.2 -// Deviation = 3.986359 -// Carrier frequency = 867.999878 -// Manchester enable = false -// Bit rate = 1.2 -// RX filter BW = 10.964912 - -static const registerSetting_t preferredSettings[]= -{ - {CC1200_IOCFG2, 0x06}, - {CC1200_DEVIATION_M, 0xD1}, - {CC1200_MODCFG_DEV_E, 0x00}, - {CC1200_DCFILT_CFG, 0x5D}, - {CC1200_PREAMBLE_CFG0, 0x8A}, - {CC1200_IQIC, 0xCB}, - {CC1200_CHAN_BW, 0x1f}, //high bandwidth: increase tollerance for frequency differences - //{CC1200_CHAN_BW, 0xA6}, - {CC1200_MDMCFG1, 0x40}, - {CC1200_MDMCFG0, 0x05}, - {CC1200_SYMBOL_RATE2, 0x3F}, - {CC1200_SYMBOL_RATE1, 0x75}, - {CC1200_SYMBOL_RATE0, 0x10}, - {CC1200_AGC_REF, 0x20}, - {CC1200_AGC_CS_THR, 0xEC}, - {CC1200_AGC_CFG1, 0x51}, - {CC1200_AGC_CFG0, 0x87}, - {CC1200_FIFO_CFG, 0x00}, - {CC1200_FS_CFG, 0x12}, - {CC1200_PKT_CFG2, 0x00}, - {CC1200_PKT_CFG0, 0x20}, - {CC1200_PKT_LEN, 0xFF}, - {CC1200_IF_MIX_CFG, 0x1C}, - {CC1200_FREQOFF_CFG, 0x22}, - {CC1200_MDMCFG2, 0x0C}, - {CC1200_FREQ2, 0x56}, - {CC1200_FREQ1, 0xCC}, - {CC1200_FREQ0, 0xCC}, - {CC1200_IF_ADC1, 0xEE}, - {CC1200_IF_ADC0, 0x10}, - {CC1200_FS_DIG1, 0x07}, - {CC1200_FS_DIG0, 0xAF}, - {CC1200_FS_CAL1, 0x40}, - {CC1200_FS_CAL0, 0x0E}, - {CC1200_FS_DIVTWO, 0x03}, - {CC1200_FS_DSM0, 0x33}, - {CC1200_FS_DVC0, 0x17}, - {CC1200_FS_PFD, 0x00}, - {CC1200_FS_PRE, 0x6E}, - {CC1200_FS_REG_DIV_CML, 0x1C}, - {CC1200_FS_SPARE, 0xAC}, - {CC1200_FS_VCO0, 0xB5}, - {CC1200_XOSC5, 0x0E}, - {CC1200_XOSC1, 0x03}, -}; -/*---------------------------------------------------------------------------*/ -/* Global linkage: symbol name must be different in each exported file! */ -const cc1200_rf_cfg_t cc1200_868_fsk_1_2kbps = { - .cfg_descriptor = rf_cfg_descriptor, - .register_settings = preferredSettings, - .size_of_register_settings = sizeof(preferredSettings), - .tx_pkt_lifetime = (2 * RTIMER_SECOND), - .tx_rx_turnaround = (RTIMER_SECOND / 2), - .chan_center_freq0 = RF_CFG_CHAN_CENTER_F0, - .chan_spacing = RF_CFG_CHAN_SPACING, - .min_channel = RF_CFG_MIN_CHANNEL, - .max_channel = RF_CFG_MAX_CHANNEL, - .max_txpower = RF_CFG_MAX_TXPOWER, - .cca_threshold = RF_CFG_CCA_THRESHOLD, - .rssi_offset = RF_CFG_RSSI_OFFSET, -}; -/*---------------------------------------------------------------------------*/ diff --git a/components/spi-cc1200/cc1200.c b/components/spi-cc1200/cc1200.c deleted file mode 100644 index d69e6d1..0000000 --- a/components/spi-cc1200/cc1200.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Copyright (c) 2015, Weptech elektronik GmbH Germany - * http://www.weptech.de - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "include/cc1200_troopers.h" -#include "include/driver_cc1200.h" -#include "include/driver_cc1200_statemachine.h" - -/* - * RF test mode. Blocks inside "driver_cc1200_configure()". - * - Set this parameter to 1 in order to produce an modulated carrier (PN9) - * - Set this parameter to 2 in order to produce an unmodulated carrier - * - Set this parameter to 3 in order to switch to rx synchronous mode - * The channel is set according to CC1200_DEFAULT_CHANNEL - */ -#ifndef CC1200_RF_TESTMODE -#define CC1200_RF_TESTMODE 0 -#endif - -#if CC1200_RF_TESTMODE -#undef CC1200_RF_CFG -#if CC1200_RF_TESTMODE == 1 -#define CC1200_RF_CFG cc1200_802154g_863_870_fsk_50kbps -#elif CC1200_RF_TESTMODE == 2 -#define CC1200_RF_CFG cc1200_802154g_863_870_fsk_50kbps -#elif CC1200_RF_TESTMODE == 3 -#define CC1200_RF_CFG cc1200_802154g_863_870_fsk_50kbps -#endif -#endif - - -static const char *TAG = "driver_cc1200"; - -/*---------------------------------------------------------------------------*/ -/* Configure the radio (write basic configuration). */ -void driver_cc1200_configure(CC1200* device) { - uint8_t reg; -#if CC1200_RF_TESTMODE - uint32_t freq; -#endif - INFOS("Configure begin"); - ESP_LOGI(TAG, "marc state %d", single_read(device, CC1200_MARCSTATE) & 0x1f); - /* - * As we only write registers which are different from the chip's reset - * state, let's assure that the chip is in a clean state - */ - cc1200_reset(device); - - /* Write the configuration as exported from SmartRF Studio */ - write_reg_settings(device, CC1200_RF_CFG.register_settings, CC1200_RF_CFG.size_of_register_settings); - - /* Write frequency offset */ -#if CC1200_FREQ_OFFSET - /* MSB */ - single_write(device, CC1200_FREQOFF1, (uint8_t) (CC1200_FREQ_OFFSET >> 8)); - /* LSB */ - single_write(device, CC1200_FREQOFF0, (uint8_t) (CC1200_FREQ_OFFSET)); -#endif - - /* RSSI offset */ - single_write(device, CC1200_AGC_GAIN_ADJUST, (int8_t) CC1200_RF_CFG.rssi_offset); - - /*************************************************************************** - * RF test modes needed during hardware development - **************************************************************************/ - -#if (CC1200_RF_TESTMODE == 1) || (CC1200_RF_TESTMODE == 2) - - strobe(device, CC1200_SFTX); - single_write(device, CC1200_TXFIRST, 0); - single_write(device, CC1200_TXLAST, 0); - driver_cc1200_set_txpower(CC1200_CONST_TX_POWER_MAX); - single_write(device, CC1200_PKT_CFG2, 0x02); - freq = calculate_freq(CC1200_DEFAULT_CHANNEL - CC1200_RF_CFG.min_channel); - single_write(device, CC1200_FREQ0, ((uint8_t *) &freq)[0]); - single_write(device, CC1200_FREQ1, ((uint8_t *) &freq)[1]); - single_write(device, CC1200_FREQ2, ((uint8_t *) &freq)[2]); - - printf("RF: Freq0 0x%02x", ((uint8_t *) &freq)[0]); - printf("RF: Freq1 0x%02x", ((uint8_t *) &freq)[1]); - printf("RF: Freq2 0x%02x", ((uint8_t *) &freq)[2]); - -#if (CC1200_RF_TESTMODE == 1) - single_write(device, CC1200_SYNC_CFG1, 0xE8); - single_write(device, CC1200_PREAMBLE_CFG1, 0x00); - single_write(device, CC1200_MDMCFG1, 0x46); - single_write(device, CC1200_PKT_CFG0, 0x40); - single_write(device, CC1200_FS_DIG1, 0x07); - single_write(device, CC1200_FS_DIG0, 0xAA); - single_write(device, CC1200_FS_DVC1, 0xFF); - single_write(device, CC1200_FS_DVC0, 0x17); -#endif - -#if (CC1200_RF_TESTMODE == 2) - single_write(device, CC1200_SYNC_CFG1, 0xE8); - single_write(device, CC1200_PREAMBLE_CFG1, 0x00); - single_write(device, CC1200_MDMCFG1, 0x06); - single_write(device, CC1200_PA_CFG1, 0x3F); - single_write(device, CC1200_MDMCFG2, 0x03); - single_write(device, CC1200_FS_DIG1, 0x07); - single_write(device, CC1200_FS_DIG0, 0xAA); - single_write(device, CC1200_FS_DVC0, 0x17); - single_write(device, CC1200_SERIAL_STATUS, 0x08); -#endif - - strobe(device, CC1200_STX); - - while (1) { -#if (CC1200_RF_TESTMODE == 1) - vTaskDelay(10000); - leds_off(LEDS_YELLOW); - leds_on(LEDS_RED); - vTaskDelay(10000); - leds_off(LEDS_RED); - leds_on(LEDS_YELLOW); -#else - vTaskDelay(10000); - leds_off(LEDS_GREEN); - leds_on(LEDS_RED); - vTaskDelay(10000); - leds_off(LEDS_RED); - leds_on(LEDS_GREEN); -#endif - } - -#elif (CC1200_RF_TESTMODE == 3) - - /* CS on GPIO3 */ - single_write(CC1200_IOCFG3, CC1200_IOCFG_CARRIER_SENSE); - single_write(CC1200_IOCFG2, CC1200_IOCFG_SERIAL_CLK); - single_write(CC1200_IOCFG0, CC1200_IOCFG_SERIAL_RX); - driver_cc1200_set_cca_threshold(CC1200_RF_CFG.cca_threshold); - freq = calculate_freq(CC1200_DEFAULT_CHANNEL - CC1200_RF_CFG.min_channel); - single_write(CC1200_FREQ0, ((uint8_t *) &freq)[0]); - single_write(CC1200_FREQ1, ((uint8_t *) &freq)[1]); - single_write(CC1200_FREQ2, ((uint8_t *) &freq)[2]); - strobe(CC1200_SRX); - - while (1) { - vTaskDelay(10000); - leds_off(LEDS_GREEN); - leds_on(LEDS_YELLOW); - vTaskDelay(10000); - leds_off(LEDS_YELLOW); - leds_on(LEDS_GREEN); - clock_delay_usec(1000); - - /* CS on GPIO3 */ - if (cc1200_arch_gpio3_read_pin() == 1) { - leds_on(LEDS_RED); - } else { - leds_off(LEDS_RED); - } - } - -#endif /* #if CC1200_RF_TESTMODE == ... */ - - /*************************************************************************** - * Set the stuff we need for this driver to work. Don't touch! - **************************************************************************/ - - /* GPIOx configuration */ - single_write(device, CC1200_IOCFG3, GPIO3_IOCFG); - single_write(device, CC1200_IOCFG2, GPIO2_IOCFG); - single_write(device, CC1200_IOCFG0, GPIO0_IOCFG); - - reg = single_read(device, CC1200_SETTLING_CFG); - /* - * Turn of auto calibration. This gives us better control - * over the timing (RX/TX & TX /RX turnaround!). We calibrate manually: - * - Upon wake-up (on()) - * - Before going to TX (transmit()) - * - When setting an new channel (set_channel()) - */ - reg &= ~(3 << 3); -#if CC1200_AUTOCAL - /* We calibrate when going from idle to RX or TX */ - reg |= (1 << 3); -#endif - single_write(device, CC1200_SETTLING_CFG, reg); - - /* Configure RXOFF_MODE */ - reg = single_read(device, CC1200_RFEND_CFG1); - reg &= ~(3 << 4); /* RXOFF_MODE = IDLE */ -#if RXOFF_MODE_RX - reg |= (3 << 4); /* RXOFF_MODE = RX */ -#endif - reg |= 0x0F; /* Disable RX timeout */ - single_write(device, CC1200_RFEND_CFG1, reg); - - /* Configure TXOFF_MODE */ - reg = single_read(device, CC1200_RFEND_CFG0); - reg &= ~(3 << 4); /* TXOFF_MODE = IDLE */ -#if TXOFF_MODE_RX - reg |= (3 << 4); /* TXOFF_MODE = RX */ -#endif - single_write(device, CC1200_RFEND_CFG0, reg); - - /* - * CCA Mode 0: Always give clear channel indication. - * CCA is done "by hand". Keep in mind: automatic CCA would also - * affect the transmission of the ACK and is not implemented yet! - */ -#if CC1200_802154G - single_write(device, CC1200_PKT_CFG2, (1 << 5)); -#else - single_write(device, CC1200_PKT_CFG2, 0x00); -#endif - - /* Configure appendix */ - reg = single_read(device, CC1200_PKT_CFG1); -#if APPEND_STATUS - reg |= (1 << 0); -#else - reg &= ~(1 << 0); -#endif - single_write(device, CC1200_PKT_CFG1, reg); - - /* Variable packet length mode */ - reg = single_read(device, CC1200_PKT_CFG0); - reg &= ~(3 << 5); - reg |= (1 << 5); - single_write(device, CC1200_PKT_CFG0, reg); - -#ifdef FIFO_THRESHOLD - /* FIFO threshold */ - single_write(device, CC1200_FIFO_CFG, FIFO_THRESHOLD); -#endif - - INFOS("configure done"); -} -/*---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------*/ -/* - * Netstack API radio driver functions - */ -/*---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------*/ -esp_err_t cc1200_init(CC1200* device) { - ESP_LOGD(TAG, "init called"); - INFO("testing INFO"); - ESP_LOGD(TAG, "^^^ tested INFO?"); - - INFOS(CC1200_RF_CFG.cfg_descriptor); - - if (!(rf_flags & RF_INITIALIZED)) { - /* initialize mutex for SPI access */ - if (device->mutex == NULL) { - device->mutex = xSemaphoreCreateMutex(); - if (device->mutex != NULL) xSemaphoreGive(device->mutex); - } - - /* Perform low level initialization */ - cc1200_arch_init(device); - - if (device->spi_semaphore == NULL) { - device->spi_semaphore = xSemaphoreCreateMutex(); - xSemaphoreGive(device->spi_semaphore); - } - - /* Configure GPIO interrupts */ - SETUP_GPIO_INTERRUPTS(device); - - /* Write initial configuration */ - driver_cc1200_configure(device); - - /* Enable address filtering + auto ack */ - // rx_mode_value = (RADIO_RX_MODE_AUTOACK | RADIO_RX_MODE_ADDRESS_FILTER); - - /* Enable CCA */ - // tx_mode_value = (RADIO_TX_MODE_SEND_ON_CCA); - - /* Set output power */ - driver_cc1200_set_txpower(device, CC1200_RF_CFG.max_txpower); - - /* Adjust CAA threshold */ - driver_cc1200_set_cca_threshold(device, CC1200_RF_CFG.cca_threshold); - - /* Setup queues */ - cc1200_tx_queue = xQueueCreate(10, sizeof(cc1200_message)); - cc1200_rx_queue = xQueueCreate(10, sizeof(cc1200_message)); - cc1200_cmd_queue = xQueueCreate(10, sizeof(cc1200_cmd)); - - /* Setup RX thread */ - cc1200_event_group = xEventGroupCreate(); - xTaskCreate(&cc1200_event_task, "cc1200 events", 2048, device, 10, NULL); - - /* We are on + initialized at this point */ - rf_flags |= (RF_INITIALIZED | RF_ON); - - /* Set default channel. This will also force initial calibration! */ - driver_cc1200_set_frequency(868 * 1000 * 1000); - - /* - * We have to call off() before on() because on() relies on the - * configuration of the GPIO0 pin - */ - cc1200_arch_gpio0_enable_irq(device); - } - - return cc1200_troopers_init(); -} - -esp_err_t driver_cc1200_rx_packet(cc1200_message *msg) { - msg->data = NULL; - msg->len = 0; - if (xQueueReceive(cc1200_rx_queue, msg, 1000) == pdPASS) - return ESP_OK; - else - return ESP_FAIL; -} - -esp_err_t driver_cc1200_tx_packet(uint8_t *data, uint8_t len) { - ESP_LOGD(TAG, "transmitting packet..."); - xEventGroupClearBits(cc1200_event_group, CC1200_EVENT_TX_FINISHED); - - cc1200_message msg; - msg.len = len; - msg.data = malloc(msg.len + 1); - memcpy(msg.data, data, msg.len); - msg.data[msg.len] = 0x00; - - if (xQueueSend(cc1200_tx_queue, (void *) &msg, (TickType_t) 1) != pdPASS) { - WARNING("Failed to queue received packet, dropping"); - free(msg.data); - return ESP_FAIL; - } - - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_HANDLE_TX); - EventBits_t event_bits = xEventGroupWaitBits(cc1200_event_group, CC1200_EVENT_TX_FINISHED, pdFALSE, pdFALSE, 1000 / portTICK_PERIOD_MS); - - if (event_bits & CC1200_EVENT_TX_FINISHED) - return ESP_OK; - else - return ESP_FAIL; -} - -uint8_t driver_cc1200_read_reg(CC1200* device, uint16_t addr) { - uint8_t ret = DEVICE_BUSY; -// if (xSemaphoreTake(device->spi_semaphore, 1000 / portTICK_PERIOD_MS) == pdTRUE) { - ret = single_read(device, addr); -// xSemaphoreGive(device->spi_semaphore); -// } - return ret; -} - -uint8_t driver_cc1200_write_reg(CC1200* device, uint16_t addr, uint8_t data) { - uint8_t ret = DEVICE_BUSY; -// if (xSemaphoreTake(device->spi_semaphore, 1000 / portTICK_PERIOD_MS) == pdTRUE) { - ret = single_write(device, addr, data); -// xSemaphoreGive(device->spi_semaphore); -// } - return ret; -} - -esp_err_t driver_cc1200_send_cmd(uint8_t cmd, uint32_t arg) { - cc1200_cmd cc1200cmd; - cc1200cmd.cmd = cmd; - cc1200cmd.arg = arg; - - if (xQueueSend(cc1200_cmd_queue, (void *) &cc1200cmd, (TickType_t) 1) != pdPASS) { - WARNING("Failed to queue received packet, dropping"); - return ESP_FAIL; - } - - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_CMD); - EventBits_t event_bits = xEventGroupWaitBits(cc1200_event_group, CC1200_EVENT_CMD_DONE, pdFALSE, pdFALSE, 1000 / portTICK_PERIOD_MS); - - if (event_bits & CC1200_EVENT_CMD_DONE) - return ESP_OK; - else - return ESP_FAIL; -} - -int driver_cc1200_set_frequency(uint32_t freq) { - if (freq < 863000000 || freq > 870000000) { - return CHANNEL_OUT_OF_LIMITS; - } - - return driver_cc1200_send_cmd(CMD_SET_FREQUENCY, freq); -} - -uint32_t driver_cc1200_get_frequency(CC1200* device) { - uint32_t freq = 0; -// if (xSemaphoreTake(device->spi_semaphore, 1000 / portTICK_PERIOD_MS) == pdTRUE) { - ((uint8_t *) &freq)[0] = single_read(device, CC1200_FREQ0); - ((uint8_t *) &freq)[1] = single_read(device, CC1200_FREQ1); - ((uint8_t *) &freq)[2] = single_read(device, CC1200_FREQ2); - - freq = freq * FREQ_DIVIDER / FREQ_MULTIPLIER; -// } - -// xSemaphoreGive(device->spi_semaphore); - return freq; -} - -int driver_cc1200_get_state(CC1200* device) { return single_read(device, CC1200_MARCSTATE) & 0x1f; } - -esp_err_t driver_cc1200_on() { return driver_cc1200_send_cmd(CMD_ON, 0); } - -esp_err_t driver_cc1200_off() { return driver_cc1200_send_cmd(CMD_OFF, 0); } diff --git a/components/spi-cc1200/cc1200_hal.c b/components/spi-cc1200/cc1200_hal.c deleted file mode 100644 index b15e25f..0000000 --- a/components/spi-cc1200/cc1200_hal.c +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include - -#include "driver/gpio.h" -#include "driver_cc1200.h" - -static const char* TAG = "driver_cc1200"; - -// static void IRAM_ATTR ili9341_spi_pre_transfer_callback(spi_transaction_t *t) { -// CC1200* device = ((CC1200*) t->user); -// gpio_set_level(device->pin_dcx, device->dc_level); -// } - -esp_err_t cc1200_arch_init(CC1200* device) { - esp_err_t res; - - if (device->pin_cs < 0) return ESP_FAIL; - - // Initialize chip select GPIO pin - res = gpio_set_direction(device->pin_cs, GPIO_MODE_OUTPUT); - if (res != ESP_OK) return res; - - if (device->spi_device == NULL) { - spi_device_interface_config_t devcfg = { - .command_bits = 0, - .address_bits = 0, - .dummy_bits = 0, - .mode = 0, // SPI mode 0 - .duty_cycle_pos = 128, - .cs_ena_pretrans = 0, - .cs_ena_posttrans = 0, - .clock_speed_hz = device->spi_speed, -// .spics_io_num = device->pin_cs, - .spics_io_num = -1, - .input_delay_ns = 0, - .queue_size = 1, - .pre_cb = NULL, - .post_cb = NULL, - }; - res = spi_bus_add_device(device->spi_bus, &devcfg, &device->spi_device); - if (res != ESP_OK) return res; - } - - ESP_LOGD(TAG, "SPI bus initialised"); - return ESP_OK; -} - -// set IOCFG2 to 54 for 40khz clock out on GPIO2. -// IOCFG2 is addr 0x01 - -#define CMD_WR 0 -#define CMD_RD 2 - -void cc1200_arch_spi_select(CC1200* device) { gpio_set_level(device->pin_cs, 0); } - -void cc1200_arch_spi_deselect(CC1200* device) { gpio_set_level(device->pin_cs, 1); } - -uint8_t cc1200_arch_spi_rw_byte(CC1200* device, uint8_t c) { - uint8_t rx; - spi_transaction_t t = { - .tx_buffer = &c, - .rx_buffer = &rx, - .length = 8 * 1, - }; - esp_err_t res = spi_device_transmit(device->spi_device, &t); - if (res != ESP_OK) { - ESP_LOGE(TAG, "failed to write spi: %d", res); - } - return rx; -} - -int cc1200_arch_spi_rw(CC1200* device, uint8_t* read_buf, const uint8_t* write_buf, uint16_t len) { - spi_transaction_t t = { - .tx_buffer = write_buf, - .rx_buffer = read_buf, - .length = 8 * len, - }; -// if (device->spi_semaphore != NULL) xSemaphoreTake(device->spi_semaphore, portMAX_DELAY); - esp_err_t res = spi_device_transmit(device->spi_device, &t); -// if (device->spi_semaphore != NULL) xSemaphoreGive(device->spi_semaphore); - return res; -} - -void gpio0_isr(void* arg) { cc1200_rx_interrupt(); } - -void cc1200_arch_gpio0_setup_irq(CC1200* device, int rising) { - gpio_isr_handler_add(device->pin_intr, gpio0_isr, NULL); - - gpio_config_t io_conf = { - .intr_type = GPIO_INTR_NEGEDGE, - .mode = GPIO_MODE_INPUT, - .pin_bit_mask = 1LL << device->pin_intr, - }; - - gpio_config(&io_conf); -} - -void cc1200_arch_gpio0_enable_irq(CC1200* device) { gpio_intr_enable(device->pin_intr); } - -void cc1200_arch_gpio0_disable_irq(CC1200* device) { gpio_intr_disable(device->pin_intr); } - -int cc1200_arch_gpio0_read_pin(CC1200* device) { - uint8_t in; - in = gpio_get_level(device->pin_intr); - ESP_LOGI(TAG, "gpio0 level: %d", in); - return in; -} diff --git a/components/spi-cc1200/cc1200_spi.c b/components/spi-cc1200/cc1200_spi.c deleted file mode 100644 index 9c78ac9..0000000 --- a/components/spi-cc1200/cc1200_spi.c +++ /dev/null @@ -1,102 +0,0 @@ - -#include "include/driver_cc1200.h" - -/* Send a command strobe. */ -uint8_t strobe(CC1200* device, uint8_t strobe) { - if (xSemaphoreTake(device->spi_semaphore, portMAX_DELAY) != pdTRUE) return ESP_ERR_TIMEOUT; // Wait for SPI mutex to become available - cc1200_arch_spi_select(device); - uint8_t res = cc1200_arch_spi_rw_byte(device, strobe); - cc1200_arch_spi_deselect(device); - xSemaphoreGive(device->spi_semaphore); - return res; -} -/*---------------------------------------------------------------------------*/ -/* Reset CC1200. */ -esp_err_t cc1200_reset(CC1200* device) { - if (xSemaphoreTake(device->spi_semaphore, portMAX_DELAY) != pdTRUE) return ESP_ERR_TIMEOUT; // Wait for SPI mutex to become available - cc1200_arch_spi_rw_byte(device, CC1200_SRES); - /* - * Here we should wait for SO to go low again. - * As we don't have access to this pin we just wait for 100µs. - */ - vTaskDelay(10); - xSemaphoreGive(device->spi_semaphore); - return ESP_OK; -} - -/*---------------------------------------------------------------------------*/ -/* Write a single byte to the specified address. */ -uint8_t single_write(CC1200* device, uint16_t addr, uint8_t val) { - if (xSemaphoreTake(device->spi_semaphore, portMAX_DELAY) != pdTRUE) return ESP_ERR_TIMEOUT; // Wait for SPI mutex to become available - cc1200_arch_spi_select(device); - if (CC1200_IS_EXTENDED_ADDR(addr)) { - cc1200_arch_spi_rw_byte(device, CC1200_EXTENDED_WRITE_CMD); - cc1200_arch_spi_rw_byte(device, (uint8_t) addr); - } else { - cc1200_arch_spi_rw_byte(device, addr | CC1200_WRITE_BIT); - } - uint8_t res = cc1200_arch_spi_rw_byte(device, val); - cc1200_arch_spi_deselect(device); - xSemaphoreGive(device->spi_semaphore); - return res; -} -/*---------------------------------------------------------------------------*/ -/* Read a single byte from the specified address. */ -uint8_t single_read(CC1200* device, uint16_t addr) { - if (xSemaphoreTake(device->spi_semaphore, portMAX_DELAY) != pdTRUE) return ESP_ERR_TIMEOUT; // Wait for SPI mutex to become available - cc1200_arch_spi_select(device); - if (CC1200_IS_EXTENDED_ADDR(addr)) { - cc1200_arch_spi_rw_byte(device, CC1200_EXTENDED_READ_CMD); - cc1200_arch_spi_rw_byte(device, (uint8_t) addr); - } else { - cc1200_arch_spi_rw_byte(device, addr | CC1200_READ_BIT); - } - uint8_t res = cc1200_arch_spi_rw_byte(device, 0); - cc1200_arch_spi_deselect(device); - xSemaphoreGive(device->spi_semaphore); - return res; -} -/*---------------------------------------------------------------------------*/ -/* Write a burst of bytes starting at the specified address. */ -esp_err_t burst_write(CC1200* device, uint16_t addr, const uint8_t *data, uint8_t data_len) { - if (xSemaphoreTake(device->spi_semaphore, portMAX_DELAY) != pdTRUE) return ESP_ERR_TIMEOUT; // Wait for SPI mutex to become available - cc1200_arch_spi_select(device); - if (CC1200_IS_EXTENDED_ADDR(addr)) { - cc1200_arch_spi_rw_byte(device, CC1200_EXTENDED_BURST_WRITE_CMD); - cc1200_arch_spi_rw_byte(device, (uint8_t) addr); - } else { - cc1200_arch_spi_rw_byte(device, addr | CC1200_WRITE_BIT | CC1200_BURST_BIT); - } - esp_err_t res = cc1200_arch_spi_rw(device, NULL, data, data_len); - cc1200_arch_spi_deselect(device); - xSemaphoreGive(device->spi_semaphore); - return res; -} -/*---------------------------------------------------------------------------*/ -/* Read a burst of bytes starting at the specified address. */ -esp_err_t burst_read(CC1200* device, uint16_t addr, uint8_t *data, uint8_t data_len) { - if (xSemaphoreTake(device->spi_semaphore, portMAX_DELAY) != pdTRUE) return ESP_ERR_TIMEOUT; // Wait for SPI mutex to become available - cc1200_arch_spi_select(device); - if (CC1200_IS_EXTENDED_ADDR(addr)) { - cc1200_arch_spi_rw_byte(device, CC1200_EXTENDED_BURST_READ_CMD); - cc1200_arch_spi_rw_byte(device, (uint8_t) addr); - } else { - cc1200_arch_spi_rw_byte(device, addr | CC1200_READ_BIT | CC1200_BURST_BIT); - } - esp_err_t res = cc1200_arch_spi_rw(device, data, NULL, data_len); - cc1200_arch_spi_deselect(device); - xSemaphoreGive(device->spi_semaphore); - return res; -} -/*---------------------------------------------------------------------------*/ -/* Write a list of register settings. */ -void write_reg_settings(CC1200* device, const registerSetting_t *reg_settings, uint16_t sizeof_reg_settings) { - int i = sizeof_reg_settings / sizeof(registerSetting_t); - - if (reg_settings != NULL) { - while (i--) { - single_write(device, reg_settings->addr, reg_settings->val); - reg_settings++; - } - } -} diff --git a/components/spi-cc1200/cc1200_statemachine.c b/components/spi-cc1200/cc1200_statemachine.c deleted file mode 100644 index 2dda42b..0000000 --- a/components/spi-cc1200/cc1200_statemachine.c +++ /dev/null @@ -1,895 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "include/cc1200_troopers.h" -#include "include/driver_cc1200.h" - -#define RADIO_TX_ERR 1 -#define RADIO_TX_OK 0 -#define RADIO_TX_MODE_SEND_ON_CCA 1 -#define RADIO_TX_COLLISION 2 - -#define CMD_OK 0 - - -static const char *TAG = "driver_cc1200"; - -QueueHandle_t cc1200_tx_queue; -QueueHandle_t cc1200_rx_queue; -QueueHandle_t cc1200_cmd_queue; -EventGroupHandle_t cc1200_event_group; - -/*---------------------------------------------------------------------------*/ -/* Variables */ -/*---------------------------------------------------------------------------*/ -/* - * The current channel in the range CC1200_RF_CHANNEL_MIN - * to CC1200_RF_CHANNEL_MAX - */ -/* The radio drivers state */ -uint8_t rf_flags = 0; -#if !CC1200_AUTOCAL && CC1200_CAL_TIMEOUT_SECONDS -/* Use a timeout to decide when to calibrate */ -unsigned long cal_timer; -#endif - -/* processes a command for the radio */ -void cc1200_handle_cmd(CC1200* device, cc1200_cmd *cmd); -void cc1200_cmd_set_frequency(CC1200* device, cc1200_cmd *cmd); -/* handles the reception of a packet */ -static void cc1200_handle_rx(CC1200* device); -/* Send the packet that has previously been prepared. */ -static int cc1200_handle_tx(CC1200* device, cc1200_message *msg); -/* - * Perform a Clear-Channel Assessment (CCA) to find out if there is - * a packet in the air or not. - */ -static int channel_clear(CC1200* device); -/* Enter IDLE state. */ -static void enter_idle_state(CC1200* device); -/* Enter RX state. */ -static void idle_calibrate_rx(CC1200* device); -/* Restart RX from within RX interrupt. */ -static void enter_rx_state(CC1200* device); -/* Fill TX FIFO, start TX and wait for TX to complete (blocking!). */ -static int idle_tx_rx(CC1200* device, const uint8_t *payload, uint16_t payload_len); -/* Calculate FREQ register from channel */ -static uint32_t calculate_freq(uint8_t channel); -/* Validate address and send ACK if requested. */ -static int addr_check_auto_ack(uint8_t *frame, uint16_t frame_len); -/* Turn the radio on. */ -static int cc1200_cmd_on(CC1200* device); -/* Turn the radio off. */ -static int cc1200_cmd_off(CC1200* device); -/* Return the radio's state. */ -static uint8_t state(CC1200* device); -/* Perform manual calibration. */ -static void calibrate(CC1200* device); - -/*---------------------------------------------------------------------------*/ -/* - * The CC1200 interrupt handler: called by the hardware interrupt - * handler, which is defined as part of the cc1200-arch interface. - */ -int cc1200_rx_interrupt(void) { - xEventGroupSetBitsFromISR(cc1200_event_group, CC1200_EVENT_HANDLE_RX, false); - return 0; -} - -/*---------------------------------------------------------------------------*/ -/* Handle tasks left over from rx interrupt or because SPI was locked */ -void cc1200_event_task(void *arg) { - CC1200* device = (CC1200*) arg; - while (1) { - EventBits_t event_bits = xEventGroupWaitBits( - cc1200_event_group, CC1200_EVENT_CMD | CC1200_EVENT_HANDLE_RX | CC1200_EVENT_RX_DONE | CC1200_EVENT_HANDLE_TX | CC1200_EVENT_TX_DONE, pdFALSE, - pdFALSE, 1000 / portTICK_PERIOD_MS); - if (xSemaphoreTake(device->mutex, 1000 / portTICK_PERIOD_MS) != pdTRUE) continue; - - if (event_bits & CC1200_EVENT_HANDLE_RX) { - INFOS("CC1200_EVENT_HANDLE_RX"); - xEventGroupClearBits(cc1200_event_group, CC1200_EVENT_HANDLE_RX); - cc1200_handle_rx(device); - } - - if (event_bits & CC1200_EVENT_RX_DONE) { - INFOS("CC1200_EVENT_RX_DONE"); - enter_rx_state(device); - xEventGroupClearBits(cc1200_event_group, CC1200_EVENT_RX_DONE); - } - - if (event_bits & CC1200_EVENT_CMD) { - INFOS("CC1200_EVENT_HANDLE_CMD"); - cc1200_cmd cmd; - if (xQueueReceive(cc1200_cmd_queue, &cmd, 0) == pdPASS) { - cc1200_handle_cmd(device, &cmd); - if (!uxQueueMessagesWaiting(cc1200_cmd_queue)) { - xEventGroupClearBits(cc1200_event_group, CC1200_EVENT_CMD); - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_CMD_DONE); - } - } else - xEventGroupClearBits(cc1200_event_group, CC1200_EVENT_CMD); - } - - if (event_bits & CC1200_EVENT_HANDLE_TX) { - INFOS("CC1200_EVENT_HANDLE_TX"); - INFOD(uxQueueMessagesWaiting(cc1200_tx_queue)); - if (uxQueueMessagesWaiting(cc1200_tx_queue)) { - cc1200_message msg; - if (xQueueReceive(cc1200_tx_queue, &msg, 0) == pdPASS) { - int r = cc1200_handle_tx(device, &msg); - if (r == RADIO_TX_OK) - ESP_LOGD(TAG, "transmitted ok"); - else - ESP_LOGE(TAG, "transmission failed with error code %d", r); - - free(msg.data); - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_TX_DONE); - } - } else - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_TX_FINISHED); - - xEventGroupClearBits(cc1200_event_group, CC1200_EVENT_HANDLE_TX); - } - - if (event_bits & CC1200_EVENT_TX_DONE) { - INFOS("CC1200_EVENT_TX_DONE"); - xEventGroupClearBits(cc1200_event_group, CC1200_EVENT_TX_DONE); - INFOD(uxQueueMessagesWaiting(cc1200_tx_queue)); - if (uxQueueMessagesWaiting(cc1200_tx_queue)) - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_HANDLE_TX); - else - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_TX_FINISHED); - } - - xSemaphoreGive(device->mutex); - } -} - -void cc1200_handle_cmd(CC1200* device, cc1200_cmd *cmd) { - if (cmd->cmd == CMD_SET_FREQUENCY) - cc1200_cmd_set_frequency(device, cmd); - else if (cmd->cmd == CMD_ON) - cc1200_cmd_on(device); - else if (cmd->cmd == CMD_OFF) - cc1200_cmd_off(device); -} - -/*---------------------------------------------------------------------------*/ -/* Send the packet that has previously been prepared. */ -static int cc1200_handle_tx(CC1200* device, cc1200_message *msg) { - uint8_t was_off = 0; - int ret = RADIO_TX_OK; - - if ((msg->len < ACK_LEN) || (msg->len > CC1200_MAX_PAYLOAD_LEN)) { - ERROR("RF: Invalid payload length!"); - return RADIO_TX_ERR; - } - - /* TX ongoing. Inhibit channel update & ACK as soon as possible */ - - if (!(rf_flags & RF_ON)) { - /* Radio is off - turn it on */ - was_off = 1; - cc1200_cmd_on(device); - /* Radio is in RX now (and calibrated...) */ - } - - /* Perform clear channel assessment */ - if (!channel_clear(device)) { - /* Channel occupied */ - if (was_off) { - cc1200_cmd_off(device); - } - return RADIO_TX_COLLISION; - } - - /* - * Make sure we start from a sane state. enter_idle_state(device) also disables - * the GPIO interrupt(s). - */ - enter_idle_state(device); - -#if !CC1200_AUTOCAL - /* Perform manual calibration unless just turned on */ - if (!was_off) { - calibrate(device); - } -#endif - - INFOX(state(device)); - /* Send data using TX FIFO */ - if (idle_tx_rx(device, (const uint8_t *) msg->data, msg->len) == RADIO_TX_OK) { - /* - * TXOFF_MODE is set to RX, - * let's wait until we are in RX and turn on the GPIO IRQs - * again as they were turned off in enter_idle_state(device) - */ - - INFOX(state(device)); - BUSYWAIT_UNTIL_STATE(device, STATE_RX, CC1200_RF_CFG.tx_rx_turnaround); - INFOX(state(device)); - - ENABLE_GPIO_INTERRUPTS(device); - - } else { - /* - * Something went wrong during TX, idle_tx_rx() returns in IDLE - * state in this case. - * Turn on RX again unless we turn off anyway - */ - - ret = RADIO_TX_ERR; - if (!was_off) { -#ifdef RF_FORCE_CALIBRATION - rf_flags |= RF_FORCE_CALIBRATION; -#endif - idle_calibrate_rx(device); - } - } - - if (was_off) { - cc1200_cmd_off(device); - } - - /* TX completed */ - - return ret; -} -/*---------------------------------------------------------------------------*/ -/* - * Perform a Clear-Channel Assessment (CCA) to find out if there is a - * packet in the air or not. - */ -static int channel_clear(CC1200* device) { - ESP_LOGW(TAG, "channel_clear() disabled for now"); - return 1; /* TODO: fix this */ - uint8_t cca, was_off = 0; - - if (!(rf_flags & RF_ON)) { - /* We are off */ - was_off = 1; - cc1200_cmd_on(device); - } - - RF_ASSERT(state(device) == STATE_RX); - - /* - * At this point we should be in RX. If GPIO0 is set, we are currently - * receiving a packet, no need to check the RSSI. Or is there any situation - * when we want access the channel even if we are currently receiving a - * packet??? - */ - - if (cc1200_arch_gpio0_read_pin(device) == 1) { - /* Channel occupied */ - INFO("RF: CCA (0)"); - cca = 0; - } else { - uint8_t rssi0; - - /* Wait for CARRIER_SENSE_VALID signal */ - BUSYWAIT_UNTIL(((rssi0 = single_read(device, CC1200_RSSI0)) & CC1200_CARRIER_SENSE_VALID), RTIMER_SECOND / 100); - RF_ASSERT(rssi0 & CC1200_CARRIER_SENSE_VALID); - - if (rssi0 & CC1200_CARRIER_SENSE) { - /* Channel occupied */ - INFO("RF: CCA (0)"); - cca = 0; - } else { - /* Channel clear */ - INFO("RF: CCA (1)"); - cca = 1; - } - } - - if (was_off) { - cc1200_cmd_off(device); - } - - return cca; -} - -/*---------------------------------------------------------------------------*/ -/* Enter IDLE state. */ -static void enter_idle_state(CC1200* device) { - uint8_t s; - - DISABLE_GPIO_INTERRUPTS(device); - - TX_LEDS_OFF(); - RX_LEDS_OFF(); - - s = state(device); - - if (s == STATE_IDLE) { - return; - } else if (s == STATE_RX_FIFO_ERR) { - WARNING("RF: RX FIFO error!"); - strobe(device, CC1200_SFRX); - } else if (s == STATE_TX_FIFO_ERR) { - WARNING("RF: TX FIFO error!"); - strobe(device, CC1200_SFTX); - } - - strobe(device, CC1200_SIDLE); - BUSYWAIT_UNTIL_STATE(device, STATE_IDLE, RTIMER_SECOND / 100); - -} /* enter_idle_state(device), 21.05.2015 */ -/*---------------------------------------------------------------------------*/ -/* Enter RX state. */ - -/* Perform manual calibration. */ -static void calibrate(CC1200* device) { - INFOS("Calibrate"); - - strobe(device, CC1200_SCAL); - BUSYWAIT_UNTIL_STATE(device, STATE_CALIBRATE, RTIMER_SECOND / 100); -} - -void idle_calibrate_rx(CC1200* device) { - RF_ASSERT(state(device) == STATE_IDLE); - -#if !CC1200_AUTOCAL - calibrate(device); -#endif - - strobe(device, CC1200_SFRX); - strobe(device, CC1200_SRX); - BUSYWAIT_UNTIL_STATE(device, STATE_RX, RTIMER_SECOND / 100); - - ENABLE_GPIO_INTERRUPTS(device); -} -/*---------------------------------------------------------------------------*/ -/* Restart RX from within RX interrupt. */ -static void enter_rx_state(CC1200* device) { - uint8_t s = state(device); - - if (s == STATE_IDLE) { - /* Proceed to rx */ - } else if (s == STATE_RX_FIFO_ERR) { - WARNING("RF: RX FIFO error!"); - strobe(device, CC1200_SFRX); - } else if (s == STATE_TX_FIFO_ERR) { - WARNING("RF: TX FIFO error!"); - strobe(device, CC1200_SFTX); - } else { - strobe(device, CC1200_SIDLE); - BUSYWAIT_UNTIL_STATE(device, STATE_IDLE, RTIMER_SECOND / 100); - } - - RX_LEDS_OFF(); - - /* Clear pending GPIO interrupts */ - ENABLE_GPIO_INTERRUPTS(device); - - strobe(device, CC1200_SFRX); - strobe(device, CC1200_SRX); - BUSYWAIT_UNTIL_STATE(device, STATE_RX, RTIMER_SECOND / 100); -} -/*---------------------------------------------------------------------------*/ -/* Fill TX FIFO, start TX and wait for TX to complete (blocking!). */ -static int idle_tx_rx(CC1200* device, const uint8_t *payload, uint16_t payload_len) { -#if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) - uint16_t bytes_left_to_write; - uint8_t to_write; - const uint8_t *p; -#endif - -#if CC1200_802154G - /* Prepare PHR for 802.15.4g frames */ - struct { - uint8_t phra; - uint8_t phrb; - } phr; -#if CC1200_802154G_CRC16 - payload_len += 2; -#else - payload_len += 4; -#endif - /* Frame length */ - phr.phrb = (uint8_t) (payload_len & 0x00FF); - phr.phra = (uint8_t) ((payload_len >> 8) & 0x0007); -#if CC1200_802154G_WHITENING - /* Enable Whitening */ - phr.phra |= (1 << 3); -#endif /* #if CC1200_802154G_WHITENING */ -#if CC1200_802154G_CRC16 - /* FCS type 1, 2 Byte CRC */ - phr.phra |= (1 << 4); -#endif /* #if CC1200_802154G_CRC16 */ -#endif /* #if CC1200_802154G */ - - /* Prepare for RX */ - strobe(device, CC1200_SFRX); - - /* Flush TX FIFO */ - strobe(device, CC1200_SFTX); - -#if USE_SFSTXON - /* - * Enable synthesizer. Saves us a few µs especially if it takes - * long enough to fill the FIFO. This strobe must not be - * send before SFTX! - */ - strobe(device, CC1200_SFSTXON); -#endif - -#if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) - /* - * We already checked that GPIO2 is used if - * CC1200_MAX_PAYLOAD_LEN > 127 / 126 in the header of this file - */ - single_write(device, CC1200_IOCFG2, CC1200_IOCFG_TXFIFO_THR); -#endif - -#if CC1200_802154G - /* Write PHR */ - burst_write(device, CC1200_TXFIFO, (uint8_t *) &phr, PHR_LEN); -#else - /* Write length byte */ - burst_write(device, CC1200_TXFIFO, (uint8_t *) &payload_len, PHR_LEN); -#endif /* #if CC1200_802154G */ - - /* - * Fill FIFO with data. If SPI is slow it might make sense - * to divide this process into several chunks. - * The best solution would be to perform TX FIFO refill - * using an interrupt, but we are blocking here (= in TX) anyway... - */ - -#if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) - to_write = MIN(payload_len, (CC1200_FIFO_SIZE - PHR_LEN)); - burst_write(device, CC1200_TXFIFO, payload, to_write); - bytes_left_to_write = payload_len - to_write; - p = payload + to_write; -#else - burst_write(device, CC1200_TXFIFO, payload, payload_len); -#endif - -#if USE_SFSTXON - /* Wait for synthesizer to be ready */ - BUSYWAIT_UNTIL_STATE(device, STATE_FSTXON, RTIMER_SECOND / 100); -#endif - - /* Start TX */ - strobe(device, CC1200_STX); - INFOX(state(device)); - - /* Wait for TX to start. */ - BUSYWAIT_UNTIL((state(device) != STATE_TX), RTIMER_SECOND / 10); - INFOX(state(device)) - - /* Turned off at the latest in enter_idle_state(device) */ - TX_LEDS_ON(); - - if ((cc1200_arch_gpio0_read_pin(device) == 0) && (single_read(device, CC1200_NUM_TXBYTES) != 0)) { - /* - * TX didn't start in time. We also check NUM_TXBYES - * in case we missed the rising edge of the GPIO signal - */ - - ERROR("RF: TX doesn't start!"); -#if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) - single_write(device, CC1200_IOCFG2, GPIO2_IOCFG); -#endif - enter_idle_state(device); - - return RADIO_TX_ERR; - } - -#if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) - if (bytes_left_to_write != 0) { - rtimer_clock_t t0; - uint8_t s; - t0 = RTIMER_NOW(); - do { - if ((bytes_left_to_write != 0) && (cc1200_arch_gpio2_read_pin() == 0)) { - /* TX TIFO is drained below FIFO_THRESHOLD. Re-fill... */ - to_write = MIN(bytes_left_to_write, FIFO_THRESHOLD); - burst_write(device, CC1200_TXFIFO, p, to_write); - bytes_left_to_write -= to_write; - p += to_write; - t0 += CC1200_RF_CFG.tx_pkt_lifetime; - } - } while ((cc1200_arch_gpio0_read_pin(device) == 1) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + CC1200_RF_CFG.tx_pkt_lifetime)); - - /* - * At this point we either left TX or a timeout occurred. If all went - * well, we are in RX (or at least settling) now. - * If we didn't manage to refill the TX FIFO, an underflow might - * have occur-ed - the radio might be still in TX here! - */ - - s = state(device); - if ((s != STATE_RX) && (s != STATE_SETTLING)) { - /* - * Something bad happened. Wait for radio to enter a - * stable state (in case of an error we are in TX here) - */ - - INFOS("TX failure!"); - BUSYWAIT_UNTIL((state(device) != STATE_TX), RTIMER_SECOND / 100); - /* Re-configure GPIO2 */ - single_write(device, CC1200_IOCFG2, GPIO2_IOCFG); - enter_idle_state(device); - - return RADIO_TX_ERR; - } - - } else { - /* Wait for TX to complete */ - BUSYWAIT_UNTIL((cc1200_arch_gpio0_read_pin() == 0), CC1200_RF_CFG.tx_pkt_lifetime); - } -#else - /* Wait for TX to complete */ - BUSYWAIT_UNTIL((state(device) != STATE_TX), CC1200_RF_CFG.tx_pkt_lifetime); -#endif - - if (state(device) == STATE_TX) { - /* TX takes to long - abort */ - ERROR("RF: TX takes to long!"); -#if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) - /* Re-configure GPIO2 */ - single_write(device, CC1200_IOCFG2, GPIO2_IOCFG); -#endif - enter_idle_state(device); - - return RADIO_TX_ERR; - } - -#if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) - /* Re-configure GPIO2 */ - single_write(device, CC1200_IOCFG2, GPIO2_IOCFG); -#endif - - TX_LEDS_OFF(); - - return RADIO_TX_OK; -} - -/*---------------------------------------------------------------------------*/ -/* Check broadcast address. */ -static int is_broadcast_addr(uint8_t mode, uint8_t *addr) { - /* int i = mode == FRAME802154_SHORTADDRMODE ? 2 : 8; */ - - /* while(i-- > 0) { */ - /* if(addr[i] != 0xff) { */ - /* return 0; */ - /* } */ - /* } */ - - /* return 1; */ - return -1; -} -/*---------------------------------------------------------------------------*/ -static int addr_check_auto_ack(uint8_t *frame, uint16_t frame_len) { - /* frame802154_t info154; */ - - /* if(frame802154_parse(frame, frame_len, &info154) != 0) { */ - - /* /\* We received a valid 802.15.4 frame *\/ */ - - /* if(!(rx_mode_value & RADIO_RX_MODE_ADDRESS_FILTER) || */ - /* info154.fcf.frame_type == FRAME802154_ACKFRAME || */ - /* is_broadcast_addr(info154.fcf.dest_addr_mode, */ - /* (uint8_t *)&info154.dest_addr) || */ - /* linkaddr_cmp((linkaddr_t *)&info154.dest_addr, */ - /* &linkaddr_node_addr)) { */ - - /* /\* */ - /* * Address check succeeded or address filter disabled. */ - /* * We send an ACK in case a corresponding data frame */ - /* * is received even in promiscuous mode (if auto-ack is */ - /* * enabled)! */ - /* *\/ */ - - /* if((rx_mode_value & RADIO_RX_MODE_AUTOACK) && */ - /* info154.fcf.frame_type == FRAME802154_DATAFRAME && */ - /* info154.fcf.ack_required != 0 && */ - /* (!(rx_mode_value & RADIO_RX_MODE_ADDRESS_FILTER) || */ - /* linkaddr_cmp((linkaddr_t *)&info154.dest_addr, */ - /* &linkaddr_node_addr))) { */ - - /* /\* */ - /* * Data frame destined for us & ACK request bit set -> send ACK. */ - /* * Make sure the preamble length is configured accordingly as */ - /* * MAC timing parameters rely on this! */ - /* *\/ */ - - /* uint8_t ack[ACK_LEN] = { FRAME802154_ACKFRAME, 0, info154.seq }; */ - - /* #if (RXOFF_MODE_RX == 1) */ - /* /\* */ - /* * This turns off GPIOx interrupts. Make sure they are turned on */ - /* * in enter_rx_state(device) later on! */ - /* *\/ */ - /* enter_idle_state(device); */ - /* #endif */ - - /* idle_tx_rx((const uint8_t *)ack, ACK_LEN); */ - - /* /\* enter_rx_state(device) will follow *\/ */ - - /* return ADDR_CHECK_OK_ACK_SEND; */ - - /* } */ - - /* return ADDR_CHECK_OK; */ - - /* } else { */ - - /* return ADDR_CHECK_FAILED; */ - - /* } */ - - /* } */ - - /* return INVALID_FRAME; */ - return -1; -} - -static void cc1200_handle_rx(CC1200* device) { - /* The radio's state */ - uint8_t s; - /* The number of bytes in the RX FIFO waiting for read-out */ - uint8_t num_rxbytes; - /* The payload length read as the first byte from the RX FIFO */ - uint16_t payload_len; - - /* - * If CC1200_USE_GPIO2 is enabled, we come here either once RX FIFO - * threshold is reached (GPIO2 rising edge) - * or at the end of the packet (GPIO0 falling edge). - */ - - /* Make sure we are in a sane state. Sane means: either RX or IDLE */ - s = state(device); - if ((s == STATE_RX_FIFO_ERR) || (s == STATE_TX_FIFO_ERR)) { - ERROR("FIFO error"); - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_RX_DONE); - return; - } - - num_rxbytes = single_read(device, CC1200_NUM_RXBYTES); - - if (num_rxbytes == 0) { - /* - * This might happen from time to time because - * this function is also called by the pollhandler and / or - * from TWO interrupts which can occur at the same time. - */ - - INFOS("RX FIFO empty!"); - return; - } - -#if CC1200_802154G - struct { - uint8_t phra; - uint8_t phrb; - } phr; - - if (num_rxbytes < PHR_LEN) { - WARNING("RF: PHR incomplete!"); - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_RX_DONE); - return; - } - - burst_read(device, CC1200_RXFIFO, &phr, PHR_LEN); - payload_len = (phr.phra & 0x07); - payload_len <<= 8; - payload_len += phr.phrb; - - if (phr.phra & (1 << 4)) { - /* CRC16, payload_len += 2 */ - payload_len -= 2; - } else { - /* CRC16, payload_len += 4 */ - payload_len -= 4; - } -#else - /* Read first byte in RX FIFO (payload length) */ - burst_read(device, CC1200_RXFIFO, (uint8_t *) &payload_len, PHR_LEN); -#endif - - if (payload_len < ACK_LEN) { - /* Packet to short. Discard it */ - WARNING("RF: Packet too short!"); - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_RX_DONE); - return; - } - - if (payload_len > CC1200_MAX_PAYLOAD_LEN) { - /* Packet to long. Discard it */ - WARNING("RF: Packet to long!"); - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_RX_DONE); - return; - } - - RX_LEDS_ON(); - num_rxbytes -= PHR_LEN; - /* - * Read out remaining bytes unless FIFO is empty. - * We have at least num_rxbytes in the FIFO to be read out. - */ - - if (num_rxbytes == (payload_len + CC_APPENDIX_LEN)) { - /* - * End of packet. Read appendix (if available), check CRC - * and copy the data from temporary buffer to rx_pkt - * RSSI offset already set using AGC_GAIN_ADJUST.GAIN_ADJUSTMENT - */ - - // int ret = addr_check_auto_ack(buf, PHR_LEN); - cc1200_message msg; - msg.len = payload_len; - msg.data = malloc(num_rxbytes + 1); - burst_read(device, CC1200_RXFIFO, msg.data, num_rxbytes); - msg.data[msg.len] = 0x00; -#if APPEND_STATUS - if (msg.len >= 2) { - msg.crc_lqi = msg.data[num_rxbytes - 1]; - msg.rssi = msg.data[num_rxbytes - 1]; - } else { - msg.crc_lqi = 0x00; - msg.rssi = 0x00; - WARNING("Not enough bytes for rssi and crc_lqi"); - } -#else - msg.crc_lqi = single_read(device, CC1200_LQI_VAL); - msg.rssi = single_read(device, CC1200_RSSI1); - ; -#endif - - if (!(msg.crc_lqi & (1 << 7))) { - /* CRC error. Drop the packet */ - WARNING("CRC error!"); - free(msg.data); - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_RX_DONE); - return; - } - - if (!cc1200_troopers_cb(&msg)) { - WARNING("Received message %s", msg.data); - - if (xQueueSend(cc1200_rx_queue, (void *) &msg, (TickType_t) 1) != pdPASS) { - WARNING("Failed to queue received packet, dropping"); - free(msg.data); - } - } - } else { /* num_rxbytes != (payload_len + CC_APPENDIX_LEN) */ - /* - * We have a mismatch between the number of bytes in the RX FIFO - * and the payload_len. This would lead to an buffer overflow, - * so we catch this error here. - */ - - WARNING("RF: RX length mismatch %d %d!", num_rxbytes, payload_len); - } - - xEventGroupSetBits(cc1200_event_group, CC1200_EVENT_RX_DONE); - return; -} - -/*---------------------------------------------------------------------------*/ -/* Turn the radio on. */ -static int cc1200_cmd_on(CC1200* device) { - INFO("RF: On"); - - /* Don't turn on if we are on already */ - if (!(rf_flags & RF_ON)) { - /* Radio is IDLE now, re-configure GPIO0 (modified inside cc1200_cmd_off()) */ - driver_cc1200_configure(device); - - /* Wake-up procedure. Wait for GPIO0 to de-assert (CHIP_RDYn) */ - BUSYWAIT_UNTIL((cc1200_arch_gpio0_read_pin(device) == 0), RTIMER_SECOND / 100); - RF_ASSERT((cc1200_arch_gpio0_read_pin(device) == 0)); - - rf_flags |= RF_ON; - - /* Turn on RX */ - enter_idle_state(device); - idle_calibrate_rx(device); - enter_rx_state(device); - - } else { - INFO("RF: Already on"); - } - - return 1; -} -/*---------------------------------------------------------------------------*/ -/* Turn the radio off. */ -static int cc1200_cmd_off(CC1200* device) { - INFO("RF: Off"); - - /* Don't turn off if we are off already */ - if (rf_flags & RF_ON) { - enter_idle_state(device); - - /* - * As we use GPIO as CHIP_RDYn signal on wake-up / cc1200_cmd_on(), - * we re-configure it for CHIP_RDYn. - */ - single_write(device, CC1200_IOCFG0, CC1200_IOCFG_RXFIFO_CHIP_RDY_N); - - /* Say goodbye ... */ - strobe(device, CC1200_SPWD); - - /* Clear all but the initialized flag */ - rf_flags = RF_INITIALIZED; - -#if CC1200_USE_RX_WATCHDOG - etimer_stop(&et); -#endif /* #if CC1200_USE_RX_WATCHDOG */ - - } else { - INFO("RF: Already off"); - } - - return 1; -} - -/* Return the radio's state. */ -static uint8_t state(CC1200* device) { -#if STATE_USES_MARC_STATE - return single_read(device, CC1200_MARCSTATE) & 0x1f; -#else - return strobe(device, CC1200_SNOP) & 0x70; -#endif -} - -/*---------------------------------------------------------------------------*/ -/* Update TX power */ -void driver_cc1200_set_txpower(CC1200* device, int8_t txpower_dbm) { -// if (xSemaphoreTake(device->spi_semaphore, 1000 / portTICK_PERIOD_MS) == pdTRUE) { - uint8_t reg = single_read(device, CC1200_PA_CFG1); - - reg &= ~0x3F; - /* Up to now we don't handle the special power levels PA_POWER_RAMP < 3 */ - reg |= ((((txpower_dbm + 18) * 2) - 1) & 0x3F); - single_write(device, CC1200_PA_CFG1, reg); - -// xSemaphoreGive(device->spi_semaphore); -// } -} - -/*---------------------------------------------------------------------------*/ -/* Update CCA threshold */ -void driver_cc1200_set_cca_threshold(CC1200* device, int8_t threshold_dbm) { -// if (xSemaphoreTake(device->spi_semaphore, 1000 / portTICK_PERIOD_MS) == pdTRUE) { - single_write(device, CC1200_AGC_CS_THR, (uint8_t) threshold_dbm); -// xSemaphoreGive(device->spi_semaphore); -// } -} - -void cc1200_cmd_set_frequency(CC1200* device, cc1200_cmd *cmd) { - uint32_t freq = cmd->arg; - uint8_t was_off = 0; - - INFO("Frequency update (%.3f)", freq / 1e6); - - if (!(rf_flags & RF_ON)) { - was_off = 1; -// cc1200_cmd_on(device); - } - - enter_idle_state(device); - - freq = (freq / 1000) * FREQ_MULTIPLIER / FREQ_DIVIDER; - - single_write(device, CC1200_FREQ0, ((uint8_t *) &freq)[0]); - single_write(device, CC1200_FREQ1, ((uint8_t *) &freq)[1]); - single_write(device, CC1200_FREQ2, ((uint8_t *) &freq)[2]); - - strobe(device, CC1200_SCAL); - BUSYWAIT_UNTIL_STATE(device, STATE_CALIBRATE, RTIMER_SECOND / 100); - BUSYWAIT_UNTIL(state(device) != STATE_CALIBRATE, RTIMER_SECOND / 100); - - enter_rx_state(device); -} diff --git a/components/spi-cc1200/component.mk b/components/spi-cc1200/component.mk deleted file mode 100644 index 369ec2e..0000000 --- a/components/spi-cc1200/component.mk +++ /dev/null @@ -1,3 +0,0 @@ -# Component Makefile - -COMPONENT_ADD_INCLUDEDIRS := . diff --git a/components/spi-cc1200/include/cc1200-arch.h b/components/spi-cc1200/include/cc1200-arch.h deleted file mode 100644 index ba8bc71..0000000 --- a/components/spi-cc1200/include/cc1200-arch.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2015, Weptech elektronik GmbH Germany - * http://www.weptech.de - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - */ -#pragma once - -#include -#include "types.h" - -/*---------------------------------------------------------------------------*/ -/* - * Initialize SPI module & Pins. - * - * The function has to accomplish the following tasks: - * - Enable SPI and configure SPI (CPOL = 0, CPHA = 0) - * - Configure MISO, MOSI, SCLK accordingly - * - Configure GPIOx (input) - * - Configure RESET_N (output high) - * - Configure CSn (output high) - */ -esp_err_t cc1200_arch_init(CC1200* device); -/*---------------------------------------------------------------------------*/ -/* Select CC1200 (pull down CSn pin). */ -void cc1200_arch_spi_select(CC1200* device); -/*---------------------------------------------------------------------------*/ -/* De-select CC1200 (release CSn pin). */ -void cc1200_arch_spi_deselect(CC1200* device); -/*---------------------------------------------------------------------------*/ -/* - * Configure port IRQ for GPIO0. - * If rising == 1: configure IRQ for rising edge, else falling edge - * Interrupt has to call cc1200_rx_interrupt()! - */ -void cc1200_arch_gpio0_setup_irq(CC1200* device, int rising); - -/*---------------------------------------------------------------------------*/ -/* Reset interrupt flag and enable GPIO0 port IRQ. */ -void cc1200_arch_gpio0_enable_irq(CC1200* device); -/*---------------------------------------------------------------------------*/ -/* Disable GPIO0 port IRQ. */ -void cc1200_arch_gpio0_disable_irq(CC1200* device); -/*---------------------------------------------------------------------------*/ -/* - * Read back the status of the GPIO0 pin. - * Returns 0 if the pin is low, otherwise 1 - */ -int cc1200_arch_gpio0_read_pin(CC1200* device); -/*---------------------------------------------------------------------------*/ -/* Write a single byte via SPI, return response. */ -uint8_t cc1200_arch_spi_rw_byte(CC1200* device, uint8_t c); -/*---------------------------------------------------------------------------*/ -/* - * Write a sequence of bytes while reading back the response. - * Either read_buf or write_buf can be NULL. - */ -int cc1200_arch_spi_rw(CC1200* device, uint8_t* read_buf, const uint8_t* write_buf, uint16_t len); -/*---------------------------------------------------------------------------*/ -/* - * The CC1200 interrupt handler exported from the cc1200 driver. - * - * To be called by the hardware interrupt handler(s), - * which are defined as part of the cc1200-arch interface. - */ -int cc1200_rx_interrupt(void); diff --git a/components/spi-cc1200/include/cc1200-conf.h b/components/spi-cc1200/include/cc1200-conf.h deleted file mode 100644 index d4c55be..0000000 --- a/components/spi-cc1200/include/cc1200-conf.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2015, Weptech elektronik GmbH Germany - * http://www.weptech.de - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - */ -#pragma once - -#include "contiki.h" - -/*---------------------------------------------------------------------------*/ -/* - * Can we use GPIO2 (in addition to GPIO0)? - * - * If this is the case, we can easily handle payloads > 125 bytes - * (and even > 127 bytes). If GPIO2 is available, we use it as an indicator - * pin for RX / TX FIFO threshold. - */ -#ifdef CC1200_CONF_USE_GPIO2 -#define CC1200_USE_GPIO2 CC1200_CONF_USE_GPIO2 -#else -#define CC1200_USE_GPIO2 0 -#endif -/*---------------------------------------------------------------------------*/ -/* - * The maximum payload length the driver can handle. - * - * - If CC1200_MAX_PAYLOAD_LEN <= 125 and CC1200_USE_GPIO2 == 0, we read - * out the RX FIFO at the end of the packet. RXOFF_MODE is set to RX in this - * case. - * - If 125 < CC1200_MAX_PAYLOAD_LEN <= 127 and CC1200_USE_GPIO2 == 0, we - * also read out the RX FIFO at the end of the packet, but read out - * RSSI + LQI "by hand". In this case, we also have to restart RX - * manually because RSSI + LQI are overwritten as soon as RX re-starts. - * This will lead to an increased RX/RX turnaround time. - * - If CC1200_USE_GPIO2 is set, we can use an arbitrary payload length - * (only limited by the payload length defined in the phy header). - * - * See below for 802.15.4g support. - */ -#ifdef CC1200_CONF_MAX_PAYLOAD_LEN -#define CC1200_MAX_PAYLOAD_LEN CC1200_CONF_MAX_PAYLOAD_LEN -#else -#define CC1200_MAX_PAYLOAD_LEN 125 -#endif -/*---------------------------------------------------------------------------*/ -/* - * The RX watchdog is used to check whether the radio is in RX mode at regular - * intervals (once per second). Can be used to improve reliability especially - * if NullRDC is used. Turned of by default. - */ -#ifdef CC1200_CONF_USE_RX_WATCHDOG -#define CC1200_USE_RX_WATCHDOG CC1200_CONF_USE_RX_WATCHDOG -#else -#define CC1200_USE_RX_WATCHDOG 0 -#endif -/*---------------------------------------------------------------------------*/ -/* - * Use 802.15.4g frame format? Supports frame lenghts up to 2047 bytes! - */ -#ifdef CC1200_CONF_802154G -#define CC1200_802154G CC1200_CONF_802154G -#else -#define CC1200_802154G 0 -#endif -/*---------------------------------------------------------------------------*/ -/* - * Do we use withening in 802.15.4g mode? Set to 1 if enabled, 0 otherwise. - */ -#ifdef CC1200_CONF_802154G_WHITENING -#define CC1200_802154G_WHITENING CC1200_CONF_802154G_WHITENING -#else -#define CC1200_802154G_WHITENING 0 -#endif -/*---------------------------------------------------------------------------*/ -/* - * Do we use CRC16 in 802.15.4g mode? Set to 1 if enabled, 0 otherwise. - * - * It set to 0, we use FCS type 0: CRC32. - */ -#ifdef CC1200_CONF_802154G_CRC16 -#define CC1200_802154G_CRC16 CC1200_CONF_802154G_CRC16 -#else -/* Use FCS type 0: CRC32 */ -#define CC1200_802154G_CRC16 0 -#endif -/*---------------------------------------------------------------------------*/ -/* The RF configuration to be used. */ -#ifdef CC1200_CONF_RF_CFG -#define CC1200_RF_CFG CC1200_CONF_RF_CFG -#else -#define CC1200_RF_CFG cc1200_868_fsk_1_2kbps -#endif -/*---------------------------------------------------------------------------*/ -/* - * The frequency offset - * - * Might be hardware dependent (e.g. depending on crystal load capacitances), - * so we make it a configuration parameter. Written to FREQOFF1 / FREQOFF2. - * Signed 16 bit number, see cc1200 user's guide. - * - * TODO: Make it a parameter for set_value() / get_value() - */ -#ifdef CC1200_CONF_FREQ_OFFSET -#define CC1200_FREQ_OFFSET CC1200_CONF_FREQ_OFFSET -#else -#define CC1200_FREQ_OFFSET (0) -#endif -/*---------------------------------------------------------------------------*/ -/* - * The default channel to use. - * - * Permitted values depending on the data rate + band used are defined - * in the appropriate rf configuration file. Make sure the default value - * is within these limits! - */ -#ifdef CC1200_CONF_DEFAULT_CHANNEL -#define CC1200_DEFAULT_CHANNEL CC1200_CONF_DEFAULT_CHANNEL -#else -/* 868.325 MHz */ -#define CC1200_DEFAULT_CHANNEL 26 -#endif -/*---------------------------------------------------------------------------*/ -/* - * Wether to use auto calibration or not. - * - * If set to 0, calibration is performed manually when turning the radio - * on (on()), when transmitting (transmit()) or when changing the channel. - * Enabling auto calibration will increase turn around times + - * energy consumption. If enabled, we calibrate every time we go from - * IDLE to RX or TX. - * When RDC or channel hopping is used, there is no need to turn calibration - * on because either on() is called frequently or the channel is updated. - */ -#ifdef CC1200_CONF_AUTOCAL -#define CC1200_AUTOCAL CC1200_CONF_AUTOCAL -#else -#define CC1200_AUTOCAL 0 -#endif -/*---------------------------------------------------------------------------*/ -/* - * If CC1200_AUTOCAL is not set, we use this parameter to defer - * calibration until a certain amount of time has expired. - * - * This is what happens in detail: - * - * - We (manually) calibrate once after initialization - * - We (manually) calibrate every time we change the channel - * - We (manually) calibrate when the radio is turned on() only if - * the timeout has expired - * - We (manually) calibrate when transmitting only of the timeout has expired - * - * Set this parameter to 0 when this feature is not used. In this case we - * (manually) calibrate in all situations mentioned above. - */ -#ifdef CC1200_CONF_CAL_TIMEOUT_SECONDS -#define CC1200_CAL_TIMEOUT_SECONDS CC1200_CONF_CAL_TIMEOUT_SECONDS -#else -/* Calibrate at the latest every 15 minutes */ -#define CC1200_CAL_TIMEOUT_SECONDS 900 -#endif -/*---------------------------------------------------------------------------*/ -/* - * If defined, use these LEDS to indicate TX activity - * - * The LEDs are turned on once the radio enters TX mode - * (together with ENERGEST_ON(ENERGEST_TYPE_TRANSMIT), - * and turned of as soon as TX has completed. - */ -#ifdef CC1200_CONF_TX_LEDS -#define CC1200_TX_LEDS CC1200_CONF_TX_LEDS -#endif -/*---------------------------------------------------------------------------*/ -/* - * If defined, use these LEDS to indicate RX activity - * - * The LEDs are turned on as soon as the first byte is read out from - * the RX FIFO - */ -#ifdef CC1200_CONF_RX_LED -#define CC1200_RX_LEDS CC1200_CONF_RX_LEDS -#endif -/*---------------------------------------------------------------------------*/ diff --git a/components/spi-cc1200/include/cc1200-const.h b/components/spi-cc1200/include/cc1200-const.h deleted file mode 100644 index 4cad390..0000000 --- a/components/spi-cc1200/include/cc1200-const.h +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright (c) 2015, Weptech elektronik GmbH Germany - * http://www.weptech.de - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - */ -#pragma once - -/*---------------------------------------------------------------------------*/ -/* Register addresses exported from SmartRF Studio */ -#define CC1200_IOCFG3 0x0000 /* GPIO3 IO Pin Configuration */ -#define CC1200_IOCFG2 0x0001 /* GPIO2 IO Pin Configuration */ -#define CC1200_IOCFG1 0x0002 /* GPIO1 IO Pin Configuration */ -#define CC1200_IOCFG0 0x0003 /* GPIO0 IO Pin Configuration */ -#define CC1200_SYNC3 0x0004 /* Sync Word Configuration [31:24] */ -#define CC1200_SYNC2 0x0005 /* Sync Word Configuration [23:16] */ -#define CC1200_SYNC1 0x0006 /* Sync Word Configuration [15:8] */ -#define CC1200_SYNC0 0x0007 /* Sync Word Configuration [7:0] */ -#define CC1200_SYNC_CFG1 0x0008 /* Sync Word Detection Configuration Reg. 1 */ -#define CC1200_SYNC_CFG0 0x0009 /* Sync Word Detection Configuration Reg. 0 */ -#define CC1200_DEVIATION_M 0x000A /* Frequency Deviation Configuration */ -#define CC1200_MODCFG_DEV_E 0x000B /* Modulation Format and Frequency Deviation Configur.. */ -#define CC1200_DCFILT_CFG 0x000C /* Digital DC Removal Configuration */ -#define CC1200_PREAMBLE_CFG1 0x000D /* Preamble Length Configuration Reg. 1 */ -#define CC1200_PREAMBLE_CFG0 0x000E /* Preamble Detection Configuration Reg. 0 */ -#define CC1200_IQIC 0x000F /* Digital Image Channel Compensation Configuration */ -#define CC1200_CHAN_BW 0x0010 /* Channel Filter Configuration */ -#define CC1200_MDMCFG1 0x0011 /* General Modem Parameter Configuration Reg. 1 */ -#define CC1200_MDMCFG0 0x0012 /* General Modem Parameter Configuration Reg. 0 */ -#define CC1200_SYMBOL_RATE2 0x0013 /* Symbol Rate Configuration Exponent and Mantissa [1.. */ -#define CC1200_SYMBOL_RATE1 0x0014 /* Symbol Rate Configuration Mantissa [15:8] */ -#define CC1200_SYMBOL_RATE0 0x0015 /* Symbol Rate Configuration Mantissa [7:0] */ -#define CC1200_AGC_REF 0x0016 /* AGC Reference Level Configuration */ -#define CC1200_AGC_CS_THR 0x0017 /* Carrier Sense Threshold Configuration */ -#define CC1200_AGC_GAIN_ADJUST 0x0018 /* RSSI Offset Configuration */ -#define CC1200_AGC_CFG3 0x0019 /* Automatic Gain Control Configuration Reg. 3 */ -#define CC1200_AGC_CFG2 0x001A /* Automatic Gain Control Configuration Reg. 2 */ -#define CC1200_AGC_CFG1 0x001B /* Automatic Gain Control Configuration Reg. 1 */ -#define CC1200_AGC_CFG0 0x001C /* Automatic Gain Control Configuration Reg. 0 */ -#define CC1200_FIFO_CFG 0x001D /* FIFO Configuration */ -#define CC1200_DEV_ADDR 0x001E /* Device Address Configuration */ -#define CC1200_SETTLING_CFG 0x001F /* Frequency Synthesizer Calibration and Settling Con.. */ -#define CC1200_FS_CFG 0x0020 /* Frequency Synthesizer Configuration */ -#define CC1200_WOR_CFG1 0x0021 /* eWOR Configuration Reg. 1 */ -#define CC1200_WOR_CFG0 0x0022 /* eWOR Configuration Reg. 0 */ -#define CC1200_WOR_EVENT0_MSB 0x0023 /* Event 0 Configuration MSB */ -#define CC1200_WOR_EVENT0_LSB 0x0024 /* Event 0 Configuration LSB */ -#define CC1200_RXDCM_TIME 0x0025 /* RX Duty Cycle Mode Configuration */ -#define CC1200_PKT_CFG2 0x0026 /* Packet Configuration Reg. 2 */ -#define CC1200_PKT_CFG1 0x0027 /* Packet Configuration Reg. 1 */ -#define CC1200_PKT_CFG0 0x0028 /* Packet Configuration Reg. 0 */ -#define CC1200_RFEND_CFG1 0x0029 /* RFEND Configuration Reg. 1 */ -#define CC1200_RFEND_CFG0 0x002A /* RFEND Configuration Reg. 0 */ -#define CC1200_PA_CFG1 0x002B /* Power Amplifier Configuration Reg. 1 */ -#define CC1200_PA_CFG0 0x002C /* Power Amplifier Configuration Reg. 0 */ -#define CC1200_ASK_CFG 0x002D /* ASK Configuration */ -#define CC1200_PKT_LEN 0x002E /* Packet Length Configuration */ -#define CC1200_IF_MIX_CFG 0x2F00 /* IF Mix Configuration */ -#define CC1200_FREQOFF_CFG 0x2F01 /* Frequency Offset Correction Configuration */ -#define CC1200_TOC_CFG 0x2F02 /* Timing Offset Correction Configuration */ -#define CC1200_MARC_SPARE 0x2F03 /* MARC Spare */ -#define CC1200_ECG_CFG 0x2F04 /* External Clock Frequency Configuration */ -#define CC1200_MDMCFG2 0x2F05 /* General Modem Parameter Configuration Reg. 2 */ -#define CC1200_EXT_CTRL 0x2F06 /* External Control Configuration */ -#define CC1200_RCCAL_FINE 0x2F07 /* RC Oscillator Calibration Fine */ -#define CC1200_RCCAL_COARSE 0x2F08 /* RC Oscillator Calibration Coarse */ -#define CC1200_RCCAL_OFFSET 0x2F09 /* RC Oscillator Calibration Clock Offset */ -#define CC1200_FREQOFF1 0x2F0A /* Frequency Offset MSB */ -#define CC1200_FREQOFF0 0x2F0B /* Frequency Offset LSB */ -#define CC1200_FREQ2 0x2F0C /* Frequency Configuration [23:16] */ -#define CC1200_FREQ1 0x2F0D /* Frequency Configuration [15:8] */ -#define CC1200_FREQ0 0x2F0E /* Frequency Configuration [7:0] */ -#define CC1200_IF_ADC2 0x2F0F /* Analog to Digital Converter Configuration Reg. 2 */ -#define CC1200_IF_ADC1 0x2F10 /* Analog to Digital Converter Configuration Reg. 1 */ -#define CC1200_IF_ADC0 0x2F11 /* Analog to Digital Converter Configuration Reg. 0 */ -#define CC1200_FS_DIG1 0x2F12 /* Frequency Synthesizer Digital Reg. 1 */ -#define CC1200_FS_DIG0 0x2F13 /* Frequency Synthesizer Digital Reg. 0 */ -#define CC1200_FS_CAL3 0x2F14 /* Frequency Synthesizer Calibration Reg. 3 */ -#define CC1200_FS_CAL2 0x2F15 /* Frequency Synthesizer Calibration Reg. 2 */ -#define CC1200_FS_CAL1 0x2F16 /* Frequency Synthesizer Calibration Reg. 1 */ -#define CC1200_FS_CAL0 0x2F17 /* Frequency Synthesizer Calibration Reg. 0 */ -#define CC1200_FS_CHP 0x2F18 /* Frequency Synthesizer Charge Pump Configuration */ -#define CC1200_FS_DIVTWO 0x2F19 /* Frequency Synthesizer Divide by 2 */ -#define CC1200_FS_DSM1 0x2F1A /* FS Digital Synthesizer Module Configuration Reg. 1 */ -#define CC1200_FS_DSM0 0x2F1B /* FS Digital Synthesizer Module Configuration Reg. 0 */ -#define CC1200_FS_DVC1 0x2F1C /* Frequency Synthesizer Divider Chain Configuration .. */ -#define CC1200_FS_DVC0 0x2F1D /* Frequency Synthesizer Divider Chain Configuration .. */ -#define CC1200_FS_LBI 0x2F1E /* Frequency Synthesizer Local Bias Configuration */ -#define CC1200_FS_PFD 0x2F1F /* Frequency Synthesizer Phase Frequency Detector Con.. */ -#define CC1200_FS_PRE 0x2F20 /* Frequency Synthesizer Prescaler Configuration */ -#define CC1200_FS_REG_DIV_CML 0x2F21 /* Frequency Synthesizer Divider Regulator Configurat.. */ -#define CC1200_FS_SPARE 0x2F22 /* Frequency Synthesizer Spare */ -#define CC1200_FS_VCO4 0x2F23 /* FS Voltage Controlled Oscillator Configuration Reg.. */ -#define CC1200_FS_VCO3 0x2F24 /* FS Voltage Controlled Oscillator Configuration Reg.. */ -#define CC1200_FS_VCO2 0x2F25 /* FS Voltage Controlled Oscillator Configuration Reg.. */ -#define CC1200_FS_VCO1 0x2F26 /* FS Voltage Controlled Oscillator Configuration Reg.. */ -#define CC1200_FS_VCO0 0x2F27 /* FS Voltage Controlled Oscillator Configuration Reg.. */ -#define CC1200_GBIAS6 0x2F28 /* Global Bias Configuration Reg. 6 */ -#define CC1200_GBIAS5 0x2F29 /* Global Bias Configuration Reg. 5 */ -#define CC1200_GBIAS4 0x2F2A /* Global Bias Configuration Reg. 4 */ -#define CC1200_GBIAS3 0x2F2B /* Global Bias Configuration Reg. 3 */ -#define CC1200_GBIAS2 0x2F2C /* Global Bias Configuration Reg. 2 */ -#define CC1200_GBIAS1 0x2F2D /* Global Bias Configuration Reg. 1 */ -#define CC1200_GBIAS0 0x2F2E /* Global Bias Configuration Reg. 0 */ -#define CC1200_IFAMP 0x2F2F /* Intermediate Frequency Amplifier Configuration */ -#define CC1200_LNA 0x2F30 /* Low Noise Amplifier Configuration */ -#define CC1200_RXMIX 0x2F31 /* RX Mixer Configuration */ -#define CC1200_XOSC5 0x2F32 /* Crystal Oscillator Configuration Reg. 5 */ -#define CC1200_XOSC4 0x2F33 /* Crystal Oscillator Configuration Reg. 4 */ -#define CC1200_XOSC3 0x2F34 /* Crystal Oscillator Configuration Reg. 3 */ -#define CC1200_XOSC2 0x2F35 /* Crystal Oscillator Configuration Reg. 2 */ -#define CC1200_XOSC1 0x2F36 /* Crystal Oscillator Configuration Reg. 1 */ -#define CC1200_XOSC0 0x2F37 /* Crystal Oscillator Configuration Reg. 0 */ -#define CC1200_ANALOG_SPARE 0x2F38 /* Analog Spare */ -#define CC1200_PA_CFG3 0x2F39 /* Power Amplifier Configuration Reg. 3 */ -#define CC1200_WOR_TIME1 0x2F64 /* eWOR Timer Counter Value MSB */ -#define CC1200_WOR_TIME0 0x2F65 /* eWOR Timer Counter Value LSB */ -#define CC1200_WOR_CAPTURE1 0x2F66 /* eWOR Timer Capture Value MSB */ -#define CC1200_WOR_CAPTURE0 0x2F67 /* eWOR Timer Capture Value LSB */ -#define CC1200_BIST 0x2F68 /* MARC Built-In Self-Test */ -#define CC1200_DCFILTOFFSET_I1 0x2F69 /* DC Filter Offset I MSB */ -#define CC1200_DCFILTOFFSET_I0 0x2F6A /* DC Filter Offset I LSB */ -#define CC1200_DCFILTOFFSET_Q1 0x2F6B /* DC Filter Offset Q MSB */ -#define CC1200_DCFILTOFFSET_Q0 0x2F6C /* DC Filter Offset Q LSB */ -#define CC1200_IQIE_I1 0x2F6D /* IQ Imbalance Value I MSB */ -#define CC1200_IQIE_I0 0x2F6E /* IQ Imbalance Value I LSB */ -#define CC1200_IQIE_Q1 0x2F6F /* IQ Imbalance Value Q MSB */ -#define CC1200_IQIE_Q0 0x2F70 /* IQ Imbalance Value Q LSB */ -#define CC1200_RSSI1 0x2F71 /* Received Signal Strength Indicator Reg. 1 */ -#define CC1200_RSSI0 0x2F72 /* Received Signal Strength Indicator Reg.0 */ -#define CC1200_MARCSTATE 0x2F73 /* MARC State */ -#define CC1200_LQI_VAL 0x2F74 /* Link Quality Indicator Value */ -#define CC1200_PQT_SYNC_ERR 0x2F75 /* Preamble and Sync Word Error */ -#define CC1200_DEM_STATUS 0x2F76 /* Demodulator Status */ -#define CC1200_FREQOFF_EST1 0x2F77 /* Frequency Offset Estimate MSB */ -#define CC1200_FREQOFF_EST0 0x2F78 /* Frequency Offset Estimate LSB */ -#define CC1200_AGC_GAIN3 0x2F79 /* Automatic Gain Control Reg. 3 */ -#define CC1200_AGC_GAIN2 0x2F7A /* Automatic Gain Control Reg. 2 */ -#define CC1200_AGC_GAIN1 0x2F7B /* Automatic Gain Control Reg. 1 */ -#define CC1200_AGC_GAIN0 0x2F7C /* Automatic Gain Control Reg. 0 */ -#define CC1200_CFM_RX_DATA_OUT 0x2F7D /* Custom Frequency Modulation RX Data */ -#define CC1200_CFM_TX_DATA_IN 0x2F7E /* Custom Frequency Modulation TX Data */ -#define CC1200_ASK_SOFT_RX_DATA 0x2F7F /* ASK Soft Decision Output */ -#define CC1200_RNDGEN 0x2F80 /* Random Number Generator Value */ -#define CC1200_MAGN2 0x2F81 /* Signal Magnitude after CORDIC [16] */ -#define CC1200_MAGN1 0x2F82 /* Signal Magnitude after CORDIC [15:8] */ -#define CC1200_MAGN0 0x2F83 /* Signal Magnitude after CORDIC [7:0] */ -#define CC1200_ANG1 0x2F84 /* Signal Angular after CORDIC [9:8] */ -#define CC1200_ANG0 0x2F85 /* Signal Angular after CORDIC [7:0] */ -#define CC1200_CHFILT_I2 0x2F86 /* Channel Filter Data Real Part [16] */ -#define CC1200_CHFILT_I1 0x2F87 /* Channel Filter Data Real Part [15:8] */ -#define CC1200_CHFILT_I0 0x2F88 /* Channel Filter Data Real Part [7:0] */ -#define CC1200_CHFILT_Q2 0x2F89 /* Channel Filter Data Imaginary Part [16] */ -#define CC1200_CHFILT_Q1 0x2F8A /* Channel Filter Data Imaginary Part [15:8] */ -#define CC1200_CHFILT_Q0 0x2F8B /* Channel Filter Data Imaginary Part [7:0] */ -#define CC1200_GPIO_STATUS 0x2F8C /* General Purpose Input/Output Status */ -#define CC1200_FSCAL_CTRL 0x2F8D /* Frequency Synthesizer Calibration Control */ -#define CC1200_PHASE_ADJUST 0x2F8E /* Frequency Synthesizer Phase Adjust */ -#define CC1200_PARTNUMBER 0x2F8F /* Part Number */ -#define CC1200_PARTVERSION 0x2F90 /* Part Revision */ -#define CC1200_SERIAL_STATUS 0x2F91 /* Serial Status */ -#define CC1200_MODEM_STATUS1 0x2F92 /* Modem Status Reg. 1 */ -#define CC1200_MODEM_STATUS0 0x2F93 /* Modem Status Reg. 0 */ -#define CC1200_MARC_STATUS1 0x2F94 /* MARC Status Reg. 1 */ -#define CC1200_MARC_STATUS0 0x2F95 /* MARC Status Reg. 0 */ -#define CC1200_PA_IFAMP_TEST 0x2F96 /* Power Amplifier Intermediate Frequency Amplifier T.. */ -#define CC1200_FSRF_TEST 0x2F97 /* Frequency Synthesizer Test */ -#define CC1200_PRE_TEST 0x2F98 /* Frequency Synthesizer Prescaler Test */ -#define CC1200_PRE_OVR 0x2F99 /* Frequency Synthesizer Prescaler Override */ -#define CC1200_ADC_TEST 0x2F9A /* Analog to Digital Converter Test */ -#define CC1200_DVC_TEST 0x2F9B /* Digital Divider Chain Test */ -#define CC1200_ATEST 0x2F9C /* Analog Test */ -#define CC1200_ATEST_LVDS 0x2F9D /* Analog Test LVDS */ -#define CC1200_ATEST_MODE 0x2F9E /* Analog Test Mode */ -#define CC1200_XOSC_TEST1 0x2F9F /* Crystal Oscillator Test Reg. 1 */ -#define CC1200_XOSC_TEST0 0x2FA0 /* Crystal Oscillator Test Reg. 0 */ -#define CC1200_AES 0x2FA1 /* AES */ -#define CC1200_MDM_TEST 0x2FA2 /* MODEM Test */ -#define CC1200_RXFIRST 0x2FD2 /* RX FIFO Pointer First Entry */ -#define CC1200_TXFIRST 0x2FD3 /* TX FIFO Pointer First Entry */ -#define CC1200_RXLAST 0x2FD4 /* RX FIFO Pointer Last Entry */ -#define CC1200_TXLAST 0x2FD5 /* TX FIFO Pointer Last Entry */ -#define CC1200_NUM_TXBYTES 0x2FD6 /* TX FIFO Status */ -#define CC1200_NUM_RXBYTES 0x2FD7 /* RX FIFO Status */ -#define CC1200_FIFO_NUM_TXBYTES 0x2FD8 /* TX FIFO Status */ -#define CC1200_FIFO_NUM_RXBYTES 0x2FD9 /* RX FIFO Status */ -#define CC1200_RXFIFO_PRE_BUF 0x2FDA /* RX FIFO Status */ -#define CC1200_AES_KEY15 0x2FE0 /* Advanced Encryption Standard Key [127:120] */ -#define CC1200_AES_KEY14 0x2FE1 /* Advanced Encryption Standard Key [119:112] */ -#define CC1200_AES_KEY13 0x2FE2 /* Advanced Encryption Standard Key [111:104] */ -#define CC1200_AES_KEY12 0x2FE3 /* Advanced Encryption Standard Key [103:96] */ -#define CC1200_AES_KEY11 0x2FE4 /* Advanced Encryption Standard Key [95:88] */ -#define CC1200_AES_KEY10 0x2FE5 /* Advanced Encryption Standard Key [87:80] */ -#define CC1200_AES_KEY9 0x2FE6 /* Advanced Encryption Standard Key [79:72] */ -#define CC1200_AES_KEY8 0x2FE7 /* Advanced Encryption Standard Key [71:64] */ -#define CC1200_AES_KEY7 0x2FE8 /* Advanced Encryption Standard Key [63:56] */ -#define CC1200_AES_KEY6 0x2FE9 /* Advanced Encryption Standard Key [55:48] */ -#define CC1200_AES_KEY5 0x2FEA /* Advanced Encryption Standard Key [47:40] */ -#define CC1200_AES_KEY4 0x2FEB /* Advanced Encryption Standard Key [39:32] */ -#define CC1200_AES_KEY3 0x2FEC /* Advanced Encryption Standard Key [31:24] */ -#define CC1200_AES_KEY2 0x2FED /* Advanced Encryption Standard Key [23:16] */ -#define CC1200_AES_KEY1 0x2FEE /* Advanced Encryption Standard Key [15:8] */ -#define CC1200_AES_KEY0 0x2FEF /* Advanced Encryption Standard Key [7:0] */ -#define CC1200_AES_BUFFER15 0x2FF0 /* Advanced Encryption Standard Buffer [127:120] */ -#define CC1200_AES_BUFFER14 0x2FF1 /* Advanced Encryption Standard Buffer [119:112] */ -#define CC1200_AES_BUFFER13 0x2FF2 /* Advanced Encryption Standard Buffer [111:104] */ -#define CC1200_AES_BUFFER12 0x2FF3 /* Advanced Encryption Standard Buffer [103:93] */ -#define CC1200_AES_BUFFER11 0x2FF4 /* Advanced Encryption Standard Buffer [95:88] */ -#define CC1200_AES_BUFFER10 0x2FF5 /* Advanced Encryption Standard Buffer [87:80] */ -#define CC1200_AES_BUFFER9 0x2FF6 /* Advanced Encryption Standard Buffer [79:72] */ -#define CC1200_AES_BUFFER8 0x2FF7 /* Advanced Encryption Standard Buffer [71:64] */ -#define CC1200_AES_BUFFER7 0x2FF8 /* Advanced Encryption Standard Buffer [63:56] */ -#define CC1200_AES_BUFFER6 0x2FF9 /* Advanced Encryption Standard Buffer [55:48] */ -#define CC1200_AES_BUFFER5 0x2FFA /* Advanced Encryption Standard Buffer [47:40] */ -#define CC1200_AES_BUFFER4 0x2FFB /* Advanced Encryption Standard Buffer [39:32] */ -#define CC1200_AES_BUFFER3 0x2FFC /* Advanced Encryption Standard Buffer [31:24] */ -#define CC1200_AES_BUFFER2 0x2FFD /* Advanced Encryption Standard Buffer [23:16] */ -#define CC1200_AES_BUFFER1 0x2FFE /* Advanced Encryption Standard Buffer [15:8] */ -#define CC1200_AES_BUFFER0 0x2FFF /* Advanced Encryption Standard Buffer [7:0] */ -/*---------------------------------------------------------------------------*/ -/* Access to RX / TX FIFO */ -#define CC1200_TXFIFO 0x3F -#define CC1200_RXFIFO 0x3F -/*---------------------------------------------------------------------------*/ -/* MARC_STATE */ -#define CC1200_MARC_STATE_SLEEP 0x00 -#define CC1200_MARC_STATE_IDLE 0x01 -#define CC1200_MARC_STATE_RX 0x0D -#define CC1200_MARC_STATE_RX_FIFO_ERR 0x11 -#define CC1200_MARC_STATE_TX 0x13 -#define CC1200_MARC_STATE_TX_FIFO_ERR 0x16 -/*---------------------------------------------------------------------------*/ -/* Status byte */ -#define CC1200_STATUS_BYTE_IDLE (0 << 4) -#define CC1200_STATUS_BYTE_RX (1 << 4) -#define CC1200_STATUS_BYTE_TX (2 << 4) -#define CC1200_STATUS_BYTE_FSTXON (3 << 4) -#define CC1200_STATUS_BYTE_CALIBRATE (4 << 4) -#define CC1200_STATUS_BYTE_SETTLING (5 << 4) -#define CC1200_STATUS_BYTE_RX_FIFO_ERR (6 << 4) -#define CC1200_STATUS_BYTE_TX_FIFO_ERR (7 << 4) -/*---------------------------------------------------------------------------*/ -/* GPIO configuration */ -#define CC1200_IOCFG_RXFIFO_THR 0 -#define CC1200_IOCFG_RXFFIFO_THR_PKT 1 -#define CC1200_IOCFG_TXFIFO_THR 2 -#define CC1200_IOCFG_PKT_SYNC_RXTX 6 -#define CC1200_IOCFG_SERIAL_CLK 8 -#define CC1200_IOCFG_SERIAL_RX 9 -#define CC1200_IOCFG_CARRIER_SENSE 17 -#define CC1200_IOCFG_MARC_2PIN_STATUS_1 37 -#define CC1200_IOCFG_MARC_2PIN_STATUS_0 38 -#define CC1200_IOCFG_RXFIFO_CHIP_RDY_N 50 -/*---------------------------------------------------------------------------*/ -/* Command strobes */ -#define CC1200_SRES 0x30 -#define CC1200_SFSTXON 0x31 -#define CC1200_SXOFF 0x32 -#define CC1200_SCAL 0x33 -#define CC1200_SRX 0x34 -#define CC1200_STX 0x35 -#define CC1200_SIDLE 0x36 -#define CC1200_SPWD 0x39 -#define CC1200_SFRX 0x3A -#define CC1200_SFTX 0x3B -#define CC1200_SNOP 0x3D -/*---------------------------------------------------------------------------*/ -/* SPI access modifier */ -#define CC1200_WRITE_BIT 0x00 -#define CC1200_READ_BIT 0x80 -#define CC1200_BURST_BIT 0x40 -#define CC1200_EXTENDED_WRITE_CMD (0x2F | CC1200_WRITE_BIT) -#define CC1200_EXTENDED_BURST_WRITE_CMD (0x2F | CC1200_BURST_BIT | CC1200_WRITE_BIT) -#define CC1200_EXTENDED_READ_CMD (0x2F | CC1200_READ_BIT) -#define CC1200_EXTENDED_BURST_READ_CMD (0x2F | CC1200_BURST_BIT | CC1200_READ_BIT) -/*---------------------------------------------------------------------------*/ -#define CC1200_IS_EXTENDED_ADDR(x) (x & 0x2F00) -/*---------------------------------------------------------------------------*/ -/* RSSI0 register */ -#define CC1200_CARRIER_SENSE_VALID (1 << 1) -#define CC1200_CARRIER_SENSE (1 << 2) -/*---------------------------------------------------------------------------*/ -/* MODEM_STATUS1 register */ -#define CC1200_SYNC_FOUND (1 << 7) -#define CC1200_PQT_REACHED (1 << 1) -/*---------------------------------------------------------------------------*/ -#define CC1200_FIFO_SIZE 128 -/*---------------------------------------------------------------------------*/ -/* Output power in dBm */ -/* Up to now we don't handle the special power levels PA_POWER_RAMP < 3, hence - * the minimum tx power is -16. See update_txpower(). - */ -#define CC1200_CONST_TX_POWER_MIN (-16) -/* - * Maximum output power will propably depend on the band we use due to - * regulation issues - */ -#define CC1200_CONST_TX_POWER_MAX 14 -/*---------------------------------------------------------------------------*/ -/* CCA threshold in dBm */ -#define CC1200_CONST_CCA_THRESHOLD_MIN (-127) -#define CC1200_CONST_CCA_THRESHOLD_MAX 127 diff --git a/components/spi-cc1200/include/cc1200-rf-cfg.h b/components/spi-cc1200/include/cc1200-rf-cfg.h deleted file mode 100644 index fb529e5..0000000 --- a/components/spi-cc1200/include/cc1200-rf-cfg.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2015, Weptech elektronik GmbH Germany - * http://www.weptech.de - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - */ -#pragma once - -#include -#include - -/*---------------------------------------------------------------------------*/ -/* - * We export the register setup from SmartRF using the standard template - * "trxEB RF Settings Performance Line" and have therefore to typedef - * the following struct. - */ -typedef struct cc1200_registerSetting { - uint16_t addr; - uint8_t val; -} registerSetting_t; -/*---------------------------------------------------------------------------*/ -/* Map SmartRF typedef to reflect Contiki's naming conventions */ -typedef registerSetting_t cc1200_register_settings_t; -/*---------------------------------------------------------------------------*/ -/* This struct holds the complete configuration for a given mode */ -typedef struct cc1200_rf_cfg { - /* A string describing the mode */ - const char *cfg_descriptor; - /* A pointer to a register setup exported from SmartRF */ - const cc1200_register_settings_t *register_settings; - /* The size of the register setup */ - size_t size_of_register_settings; - /* - * TX packet lifetime. Maximum duration of a TX packet including preamble, - * synch word + phy header, payload + CRC. - */ - uint16_t tx_pkt_lifetime; - /* The maximum time it takes to switch from Tx to Rx */ - uint16_t tx_rx_turnaround; - /* Base frequency in kHz */ - uint32_t chan_center_freq0; - /* Channel spacing in Hz */ - uint32_t chan_spacing; - /* The minimum channel */ - uint8_t min_channel; - /* The maximum channel */ - uint8_t max_channel; - /* The maximum output power in dBm */ - int8_t max_txpower; - /* - * The carrier sense level used for CCA in dBm (int8_t). Limited by - * CC1200_CONST_CCA_THRESHOLD_MIN and CC1200_CONST_CCA_THRESHOLD_MAX. - */ - int8_t cca_threshold; - /* The RSSI offset in dBm. - * -99 when MDMCFG1.DVGA_GAIN=00, -81 when MDMCFG1.DVGA_GAIN=01 */ - int8_t rssi_offset; -} cc1200_rf_cfg_t; -/*---------------------------------------------------------------------------*/ diff --git a/components/spi-cc1200/include/cc1200_troopers.h b/components/spi-cc1200/include/cc1200_troopers.h deleted file mode 100644 index 99f5dab..0000000 --- a/components/spi-cc1200/include/cc1200_troopers.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "driver_cc1200.h" -#define CC1200_TROOPERS_MAX_BEHIND 500 -#define CC1200_TROOPERS_HASH_SIZE 32 // sha256 -#define CC1200_TROOPERS_CHAIN_TAIL \ - "\x65\xa1\xaf\xbd\x13\x84\x33\xc3\xbd\x29\xbb\x37\xb8\x45\xbb\xc1\xdb\x2e\xc5\x0a\x0f\xe9\xed\x9d\x48\x5d\xeb\xd2\x62\x84\xe3\xd3" -#define CC1200_TROOPERS_MAGIC 0xc0ffee00 - -#define CC1200_TROOPERS_MSGTYPE_COUNTDOWN 1 -#define CC1200_TROOPERS_MSGTYPE_TALK 2 -#define CC1200_TROOPERS_MSGTYPE_BREAK 3 -#define CC1200_TROOPERS_MSGTYPE_RESET 4 -#define CC1200_TROOPERS_MSGTYPE_COUNTDOWN_SET_TIME 5 - -extern bool driver_cc1200_troopers_animation_running; - -typedef struct cc1200_troopers_message_t { - uint32_t magic; - uint8_t type; - uint16_t payload; - // Replay protection - uint16_t msgid; - uint8_t hash[CC1200_TROOPERS_HASH_SIZE]; -} __attribute__((packed, aligned(1))) cc1200_troopers_message_t; - -typedef struct cc1200_troopers_state_t { - uint16_t msgid; - uint8_t hash[CC1200_TROOPERS_HASH_SIZE]; -} cc1200_troopers_state_t; - -esp_err_t cc1200_troopers_init(); - -bool cc1200_troopers_replay_protection(cc1200_troopers_message_t *msg); - -bool cc1200_troopers_cb(cc1200_message *msg); - -void cc1200_debug_start_countdown(); diff --git a/components/spi-cc1200/include/contiki.h b/components/spi-cc1200/include/contiki.h deleted file mode 100644 index de26b70..0000000 --- a/components/spi-cc1200/include/contiki.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -/* Contiki -> FreeRTOS porting hacks */ -#define RTIMER_SECOND 1000 - diff --git a/components/spi-cc1200/include/driver_cc1200.h b/components/spi-cc1200/include/driver_cc1200.h deleted file mode 100644 index 8806673..0000000 --- a/components/spi-cc1200/include/driver_cc1200.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include - -#include "types.h" -#include "cc1200-arch.h" -#include "cc1200-conf.h" -#include "cc1200-const.h" -#include "cc1200-rf-cfg.h" -#include "driver_cc1200_misc.h" -#include "driver_cc1200_spi.h" -#include "driver_cc1200_statemachine.h" -#include "contiki.h" - -__BEGIN_DECLS - -void driver_cc1200_configure(CC1200* device); -esp_err_t cc1200_init(CC1200* device); -uint8_t driver_cc1200_read_reg(CC1200* device, uint16_t addr); -uint8_t driver_cc1200_write_reg(CC1200* device, uint16_t addr, uint8_t data); -int cc1200_rx_interrupt(void); -esp_err_t driver_cc1200_tx_packet(uint8_t *data, uint8_t len); -esp_err_t driver_cc1200_rx_packet(cc1200_message *msg); -void driver_cc1200_set_txpower(CC1200* device, int8_t txpower_dbm); -void driver_cc1200_set_cca_threshold(CC1200* device, int8_t threshold_dbm); -int driver_cc1200_set_frequency(uint32_t freq); -uint32_t driver_cc1200_get_frequency(CC1200* device); -int driver_cc1200_get_state(CC1200* device); -int driver_cc1200_set_frequency(uint32_t freq); -esp_err_t driver_cc1200_on(); -esp_err_t driver_cc1200_off(); - -__END_DECLS diff --git a/components/spi-cc1200/include/driver_cc1200_misc.h b/components/spi-cc1200/include/driver_cc1200_misc.h deleted file mode 100644 index 078f348..0000000 --- a/components/spi-cc1200/include/driver_cc1200_misc.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef DRIVER_CC1200_MISC_H -#define DRIVER_CC1200_MISC_H - -/*---------------------------------------------------------------------------*/ -/* This is the way we handle the LEDs */ -/*---------------------------------------------------------------------------*/ -#ifdef CC1200_TX_LEDS -#define TX_LEDS_ON() leds_on(CC1200_TX_LEDS) -#define TX_LEDS_OFF() leds_off(CC1200_TX_LEDS) -#else -#define TX_LEDS_ON() -#define TX_LEDS_OFF() -#endif /* #ifdef CC1200_TX_LEDS */ - -#ifdef CC1200_RX_LEDS -#define RX_LEDS_ON() leds_on(CC1200_RX_LEDS) -#define RX_LEDS_OFF() leds_off(CC1200_RX_LEDS) -#else -#define RX_LEDS_ON() -#define RX_LEDS_OFF() -#endif /* #ifdef CC1200_RX_LEDS */ -/*---------------------------------------------------------------------------*/ - -#define BUSYWAIT_UNTIL(cond, max_time) \ - do { \ - uint32_t t0; \ - uint32_t now; \ - t0 = xTaskGetTickCount(); \ - while (!(cond)) { \ - now = xTaskGetTickCount(); \ - if (now - t0 > max_time / portTICK_PERIOD_MS) { \ - ESP_LOGE(TAG, "RF: Timeout exceeded in line %d!n", __LINE__); \ - break; \ - } \ - vTaskDelay(10); \ - } \ - } while (0) - -#define BUSYWAIT_UNTIL_STATE(X, s, t) \ - do { \ - uint32_t t0; \ - uint32_t now; \ - t0 = xTaskGetTickCount(); \ - while (state(X) != s) { \ - now = xTaskGetTickCount(); \ - if (now - t0 > t / portTICK_PERIOD_MS) { \ - ESP_LOGE(TAG, "RF: Timeout exceeded in line %d!n", __LINE__); \ - break; \ - } \ - vTaskDelay(10); \ - } \ - } while (0) - -/*---------------------------------------------------------------------------*/ -#if CC1200_USE_GPIO2 -/* Configure GPIO interrupts. GPIO0: falling, GPIO2: rising edge */ -#define SETUP_GPIO_INTERRUPTS() \ - do { \ - cc1200_arch_gpio0_setup_irq(0); \ - cc1200_arch_gpio2_setup_irq(1); \ - } while (0) -#define ENABLE_GPIO_INTERRUPTS() \ - do { \ - cc1200_arch_gpio0_enable_irq(); \ - cc1200_arch_gpio2_enable_irq(); \ - } while (0) -#define DISABLE_GPIO_INTERRUPTS() \ - do { \ - cc1200_arch_gpio0_disable_irq(); \ - cc1200_arch_gpio2_disable_irq(); \ - } while (0) -#else -#define SETUP_GPIO_INTERRUPTS(X) cc1200_arch_gpio0_setup_irq(X, 0) -#define ENABLE_GPIO_INTERRUPTS(X) cc1200_arch_gpio0_enable_irq(X) -#define DISABLE_GPIO_INTERRUPTS(X) cc1200_arch_gpio0_disable_irq(X) -#endif /* #if CC1200_USE_GPIO2 */ - -/*---------------------------------------------------------------------------*/ -/* Various implementation specific defines */ -/*---------------------------------------------------------------------------*/ -/* - * The debug level to use - * - 0: No output at all - * - 1: Print errors (unrecoverable) - * - 2: Print errors + warnings (recoverable errors) - * - 3: Print errors + warnings + information (what's going on...) - */ -#define DEBUG_LEVEL 3 -/*---------------------------------------------------------------------------*/ -/* Debug macros */ -/*---------------------------------------------------------------------------*/ -#if DEBUG_LEVEL > 0 -/* Show all kind of errors e.g. when passing invalid payload length */ -#define ERROR(...) ESP_LOGE(TAG, __VA_ARGS__) -#else -#define ERROR(...) -#endif - -#if DEBUG_LEVEL > 0 -/* This macro is used to check if the radio is in a valid state */ -#define RF_ASSERT(condition) \ - do { \ - if (!(condition)) { \ - ESP_LOGE(TAG, "RF: Assertion failed in line %d", __LINE__); \ - } \ - } while (0) -#else -#define RF_ASSERT(condition) -#endif - -#if DEBUG_LEVEL > 1 -/* Show warnings e.g. for FIFO errors */ -#define WARNING(...) ESP_LOGW(TAG, __VA_ARGS__) -#else -#define WARNING(...) -#endif - -#if DEBUG_LEVEL > 2 -/* We just print out what's going on */ -#define INFO(...) ESP_LOGI(TAG, __VA_ARGS__) -#else -#define INFO(...) -#endif - -#define trc INFO("%s():%d", __func__, __LINE__); -#define INFOX(x) INFO("%s():%d " #x " = 0x%x", __func__, __LINE__, (x)); -#define INFOD(x) INFO("%s():%d " #x " = %d", __func__, __LINE__, (x)); -#define INFOS(x) INFO("%s():%d %s", __func__, __LINE__, (x)); - -#endif diff --git a/components/spi-cc1200/include/driver_cc1200_spi.h b/components/spi-cc1200/include/driver_cc1200_spi.h deleted file mode 100644 index 0380cf4..0000000 --- a/components/spi-cc1200/include/driver_cc1200_spi.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -/* Send a command strobe. */ -uint8_t strobe(CC1200* device, uint8_t strobe); -/* Reset CC1200. */ -esp_err_t cc1200_reset(CC1200* device); -/* Write a single byte to the specified address. */ -uint8_t single_write(CC1200* device, uint16_t addr, uint8_t value); -/* Read a single byte from the specified address. */ -uint8_t single_read(CC1200* device, uint16_t addr); -/* Write a burst of bytes starting at the specified address. */ -esp_err_t burst_write(CC1200* device, uint16_t addr, const uint8_t *data, uint8_t data_len); -/* Read a burst of bytes starting at the specified address. */ -esp_err_t burst_read(CC1200* device, uint16_t addr, uint8_t *data, uint8_t data_len); -/* Write a list of register settings. */ -void write_reg_settings(CC1200* device, const registerSetting_t *reg_settings, uint16_t sizeof_reg_settings); diff --git a/components/spi-cc1200/include/driver_cc1200_statemachine.h b/components/spi-cc1200/include/driver_cc1200_statemachine.h deleted file mode 100644 index 786b8af..0000000 --- a/components/spi-cc1200/include/driver_cc1200_statemachine.h +++ /dev/null @@ -1,227 +0,0 @@ -#ifndef DRIVER_CC1200_STATEMACHINE_H -#define DRIVER_CC1200_STATEMACHINE_H - -#include -#include -#include -#include -#include -#include - -extern QueueHandle_t cc1200_tx_queue; -extern QueueHandle_t cc1200_rx_queue; -extern QueueHandle_t cc1200_cmd_queue; -extern EventGroupHandle_t cc1200_event_group; -#define CC1200_EVENT_HANDLE_RX (1 << 0) /* packet reception */ -#define CC1200_EVENT_RX_DONE (1 << 1) /*packet reception finished */ -#define CC1200_EVENT_HANDLE_TX (1 << 2) /*request packet to be transmitted */ -#define CC1200_EVENT_TX_DONE (1 << 3) /* a packet transmission has finished */ -#define CC1200_EVENT_TX_FINISHED (1 << 4) /* tx queue is empty and tx has finished */ - -#define CC1200_EVENT_CMD (1 << 5) -#define CC1200_EVENT_CMD_DONE (1 << 6) - -typedef struct cc1200_cmd { - uint8_t cmd; - uint32_t arg; -} cc1200_cmd; -#define CMD_SET_FREQUENCY (1 << 0) -#define CMD_ON (1 << 1) -#define CMD_OFF (1 << 2) - -/* - * Set this parameter to 1 in order to use the MARC_STATE register when - * polling the chips's status. Else use the status byte returned when sending - * a NOP strobe. - * - * TODO: Option to be removed upon approval of the driver - */ -#define STATE_USES_MARC_STATE 0 -/* - * Set this parameter to 1 in order to speed up transmission by - * sending a FSTXON strobe before filling the FIFO. - * - * TODO: Option to be removed upon approval of the driver - */ -#define USE_SFSTXON 1 -/*---------------------------------------------------------------------------*/ -/* Phy header length */ -#if CC1200_802154G -/* Phy header = 2 byte */ -#define PHR_LEN 2 -#else -/* Phy header = length byte = 1 byte */ -#define PHR_LEN 1 -#endif /* #if CC1200_802154G */ -/*---------------------------------------------------------------------------*/ -/* Size of appendix (rssi + lqi) appended to the rx pkt */ -#define APPENDIX_LEN 2 -/*---------------------------------------------------------------------------*/ -/* Verify payload length */ -/*---------------------------------------------------------------------------*/ -#if CC1200_802154G -#if CC1200_USE_GPIO2 -#if CC1200_MAX_PAYLOAD_LEN > (2048 - PHR_LEN) -#error Payload length not supported by this driver -#endif -#else -#if CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN) -/* PHR_LEN = 2 -> we can only place 126 payload bytes bytes in the FIFO */ -#error Payload length not supported without GPIO2 -#endif -#endif /* #if CC1200_USE_GPIO2 */ -#else /* #if CC1200_802154G */ -#if CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN) -/* PHR_LEN = 1 -> we can only place 127 payload bytes bytes in the FIFO */ -#error Payload length not supported without enabling 802.15.4g mode -#endif -#endif /* #if CC1200_802154G */ -/*---------------------------------------------------------------------------*/ -/* Main driver configurations settings. Don't touch! */ -/*---------------------------------------------------------------------------*/ -#if CC1200_USE_GPIO2 -/* Use GPIO2 as RX / TX FIFO threshold indicator pin */ -#define GPIO2_IOCFG CC1200_IOCFG_RXFIFO_THR -/* This is the FIFO threshold we use */ -#define FIFO_THRESHOLD 32 -/* Turn on RX after packet reception */ -#define RXOFF_MODE_RX 1 -/* Let the CC1200 append RSSI + LQI */ -#define APPEND_STATUS 1 -#else -/* Arbitrary configuration for GPIO2 */ -#define GPIO2_IOCFG CC1200_IOCFG_MARC_2PIN_STATUS_0 -#if (CC1200_MAX_PAYLOAD_LEN <= (CC1200_FIFO_SIZE - PHR_LEN - APPENDIX_LEN)) -/* - * Read out RX FIFO at the end of the packet (GPIO0 falling edge). RX restarts - * automatically - */ -#define RXOFF_MODE_RX 1 -/* Let the CC1200 append RSSI + LQI */ -#define APPEND_STATUS 1 -#else -/* - * Read out RX FIFO at the end of the packet (GPIO0 falling edge). RX has - * to be started manually in this case - */ -#define RXOFF_MODE_RX 0 -/* No space for appendix in the RX FIFO. Read it out by hand */ -#define APPEND_STATUS 0 -#endif /* #if CC1200_MAX_PAYLOAD_LEN <= 125 */ -#endif /* #if CC1200_USE_GPIO2 */ - -/* Read out packet on falling edge of GPIO0 */ -#define GPIO0_IOCFG CC1200_IOCFG_PKT_SYNC_RXTX -/* Arbitrary configuration for GPIO3 */ -#define GPIO3_IOCFG CC1200_IOCFG_MARC_2PIN_STATUS_0 -/* Turn on RX automatically after TX */ -#define TXOFF_MODE_RX 1 -#if APPEND_STATUS -/* CC1200 places two bytes in the RX FIFO */ -#define CC_APPENDIX_LEN 2 -#else -/* CC1200 doesn't add appendix to RX FIFO */ -#define CC_APPENDIX_LEN 0 -#endif /* #if APPEND_STATUS */ -/*---------------------------------------------------------------------------*/ -/* RF configuration */ -/*---------------------------------------------------------------------------*/ -/* Import the rf configuration set by CC1200_RF_CFG */ -extern const cc1200_rf_cfg_t CC1200_RF_CFG; -/*---------------------------------------------------------------------------*/ -/* This defines the way we calculate the frequency registers */ -/*---------------------------------------------------------------------------*/ -/* XTAL frequency in kHz */ -#define XTAL_FREQ_KHZ 40000 -/* - * Divider + multiplier for calculation of FREQ registers - * f * 2^16 * 4 / 40000 = f * 2^12 / 625 (no overflow up to frequencies of - * 1048.576 MHz using uint32_t) - */ -#define LO_DIVIDER 4 -#if (XTAL_FREQ_KHZ == 40000) && (LO_DIVIDER == 4) -#define FREQ_DIVIDER 625 -#define FREQ_MULTIPLIER 4096 -#else -#error Invalid settings for frequency calculation -#endif - -/*---------------------------------------------------------------------------*/ -/* Various flags indicating the operating state of the radio. See rf_flags */ -/*---------------------------------------------------------------------------*/ -/* Radio was initialized (= init() was called) */ -#define RF_INITIALIZED 0x01 -/* The radio is on (= not in standby) */ -#define RF_ON 0x02 -/* An incoming packet was detected (at least payload length was received */ -#define RF_RX_PROCESSING_PKT 0x04 -/* TX is ongoing */ -#define RF_TX_ACTIVE 0x08 -/* Channel update required */ -#define RF_UPDATE_CHANNEL 0x10 -/* Force calibration in case we don't use CC1200 AUTOCAL + timeout */ -#if !CC1200_AUTOCAL -#if CC1200_CAL_TIMEOUT_SECONDS -#define RF_FORCE_CALIBRATION 0x40 -#endif -#endif - -/* Return value for mutx busy */ -#define DEVICE_BUSY 42 -/*---------------------------------------------------------------------------*/ -/* Return values for addr_check_auto_ack() */ -/*---------------------------------------------------------------------------*/ -/* Frame cannot be parsed / is to short */ -#define INVALID_FRAME 0 -/* Address check failed */ -#define ADDR_CHECK_FAILED 1 -/* Address check succeeded */ -#define ADDR_CHECK_OK 2 -/* Address check succeeded and ACK was send */ -#define ADDR_CHECK_OK_ACK_SEND 3 -/*---------------------------------------------------------------------------*/ -/* Return values for set_channel() */ -/*---------------------------------------------------------------------------*/ -/* Channel update was performed */ -#define CHANNEL_UPDATE_SUCCEEDED 0 -/* Busy, channel update postponed */ -#define CHANNEL_UPDATE_POSTPONED 1 -/* Invalid channel */ -#define CHANNEL_OUT_OF_LIMITS 2 -/*---------------------------------------------------------------------------*/ -/* Length of 802.15.4 ACK. We discard packets with a smaller size */ -#if CC1200_802154G -#define ACK_LEN 3 -#else -#define ACK_LEN 1 -#endif - -/*---------------------------------------------------------------------------*/ -#if STATE_USES_MARC_STATE -/* We use the MARC_STATE register to poll the chip's status */ -#define STATE_IDLE CC1200_MARC_STATE_IDLE -#define STATE_RX CC1200_MARC_STATE_RX -#define STATE_TX CC1200_MARC_STATE_TX -#define STATE_RX_FIFO_ERROR CC1200_MARC_STATE_RX_FIFO_ERR -#define STATE_TX_FIFO_ERROR CC1200_MARC_STATE_TX_FIFO_ERR -#else -/* We use the status byte read out using a NOP strobe */ -#define STATE_IDLE CC1200_STATUS_BYTE_IDLE -#define STATE_RX CC1200_STATUS_BYTE_RX -#define STATE_TX CC1200_STATUS_BYTE_TX -#define STATE_FSTXON CC1200_STATUS_BYTE_FSTXON -#define STATE_CALIBRATE CC1200_STATUS_BYTE_CALIBRATE -#define STATE_SETTLING CC1200_STATUS_BYTE_SETTLING -#define STATE_RX_FIFO_ERR CC1200_STATUS_BYTE_RX_FIFO_ERR -#define STATE_TX_FIFO_ERR CC1200_STATUS_BYTE_TX_FIFO_ERR -#endif /* #if STATE_USES_MARC_STATE */ - -extern uint8_t rf_flags; -#if !CC1200_AUTOCAL && CC1200_CAL_TIMEOUT_SECONDS -/* Use a timeout to decide when to calibrate */ -extern unsigned long cal_timer; -#endif - -void cc1200_event_task(void *arg); - -#endif diff --git a/components/spi-cc1200/include/types.h b/components/spi-cc1200/include/types.h deleted file mode 100644 index 553e2cb..0000000 --- a/components/spi-cc1200/include/types.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -typedef struct CC1200 { - // Pins - int spi_bus; - int pin_cs; - int pin_intr; - int pin_reset; - // Configuration - uint32_t spi_speed; - // Internal state - spi_device_handle_t spi_device; - bool dc_level; - // Mutex - SemaphoreHandle_t mutex; - SemaphoreHandle_t spi_semaphore; -} CC1200; - -typedef struct cc1200_message { - short len; - uint8_t *data; - int8_t rssi; - uint8_t crc_lqi; -} cc1200_message; \ No newline at end of file diff --git a/components/spi-cc1200/sdr/c1200_tx.grc b/components/spi-cc1200/sdr/c1200_tx.grc deleted file mode 100644 index e9870e4..0000000 --- a/components/spi-cc1200/sdr/c1200_tx.grc +++ /dev/null @@ -1,1382 +0,0 @@ -options: - parameters: - author: hammel - catch_exceptions: 'True' - category: '[GRC Hier Blocks]' - cmake_opt: '' - comment: '' - copyright: '' - description: '' - gen_cmake: 'On' - gen_linking: dynamic - generate_options: qt_gui - hier_block_src_path: '.:' - id: cc1200_tx - max_nouts: '0' - output_language: python - placement: (0,0) - qt_qss_theme: '' - realtime_scheduling: '' - run: 'True' - run_command: '{python} -u {filename}' - run_options: prompt - sizing_mode: fixed - thread_safe_setters: '' - title: Not titled yet - window_size: (1000,1000) - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [8, 8] - rotation: 0 - state: enabled - -blocks: -- name: bit_rate - id: variable - parameters: - comment: '' - value: '1200' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [472, 12.0] - rotation: 0 - state: enabled -- name: deviation - id: variable - parameters: - comment: '' - value: 6e3 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [280, 12.0] - rotation: 0 - state: enabled -- name: f - id: variable - parameters: - comment: '' - value: 868.00e6 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [368, 12.0] - rotation: 0 - state: enabled -- name: gain - id: variable_qtgui_dial_control - parameters: - comment: '' - gui_hint: '' - label: Tx gain - maximum: '70' - minimum: '0' - minsize: '100' - outputmsgname: value - relBackgroundColor: default - scaleFactor: '1' - showvalue: 'False' - type: int - value: '0' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [920, 12.0] - rotation: 0 - state: true -- name: samp_rate - id: variable - parameters: - comment: '' - value: 120e3 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [184, 12] - rotation: 0 - state: enabled -- name: analog_frequency_modulator_fc_0 - id: analog_frequency_modulator_fc - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - sensitivity: 2*3.14159*(deviation/samp_rate) - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [952, 172.0] - rotation: 0 - state: enabled -- name: analog_quadrature_demod_cf_0_0 - id: analog_quadrature_demod_cf - parameters: - affinity: '' - alias: '' - comment: '' - gain: 1/math.pi - maxoutbuf: '0' - minoutbuf: '0' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [336, 348.0] - rotation: 0 - state: enabled -- name: blocks_add_const_vxx_0 - id: blocks_add_const_vxx - parameters: - affinity: '' - alias: '' - comment: '' - const: '-0.5' - maxoutbuf: '0' - minoutbuf: '0' - type: float - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [592, 240.0] - rotation: 0 - state: enabled -- name: blocks_char_to_float_0 - id: blocks_char_to_float - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - scale: '1' - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [584, 172.0] - rotation: 0 - state: enabled -- name: blocks_complex_to_mag_0 - id: blocks_complex_to_mag - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [336, 464.0] - rotation: 0 - state: enabled -- name: blocks_file_sink_0_0 - id: blocks_file_sink - parameters: - affinity: '' - alias: '' - append: 'False' - comment: '' - file: /tmp/demod.fifo - type: complex - unbuffered: 'False' - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [912, 428.0] - rotation: 0 - state: disabled -- name: blocks_float_to_complex_0 - id: blocks_float_to_complex - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [704, 432.0] - rotation: 0 - state: enabled -- name: blocks_null_sink_0 - id: blocks_null_sink - parameters: - affinity: '' - alias: '' - bus_structure_sink: '[[0,],]' - comment: '' - num_inputs: '1' - type: complex - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [992, 552.0] - rotation: 0 - state: enabled -- name: blocks_repeat_0 - id: blocks_repeat - parameters: - affinity: '' - alias: '' - comment: '' - interp: int(samp_rate / bit_rate) - maxoutbuf: '0' - minoutbuf: '0' - type: float - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [784, 204.0] - rotation: 0 - state: enabled -- name: blocks_unpack_k_bits_bb_0 - id: blocks_unpack_k_bits_bb - parameters: - affinity: '' - alias: '' - comment: '' - k: '8' - maxoutbuf: '0' - minoutbuf: '0' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [392, 244.0] - rotation: 0 - state: true -- name: fosphor_qt_sink_c_0_0 - id: fosphor_qt_sink_c - parameters: - affinity: '' - alias: '' - comment: '' - freq_center: f - freq_span: samp_rate - gui_hint: '' - maxoutbuf: '0' - minoutbuf: '0' - wintype: window.WIN_BLACKMAN_hARRIS - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [328, 524.0] - rotation: 0 - state: enabled -- name: low_pass_filter_0 - id: low_pass_filter - parameters: - affinity: '' - alias: '' - beta: '6.76' - comment: '' - cutoff_freq: 'deviation ' - decim: '1' - gain: '1' - interp: '1' - maxoutbuf: '0' - minoutbuf: '0' - samp_rate: samp_rate - type: fir_filter_ccf - width: 'deviation ' - win: window.WIN_HAMMING - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [1168, 124.0] - rotation: 0 - state: true -- name: network_socket_pdu_0 - id: network_socket_pdu - parameters: - affinity: '' - alias: '' - comment: '' - host: '' - maxoutbuf: '0' - minoutbuf: '0' - mtu: '10000' - port: '52001' - tcp_no_delay: 'True' - type: UDP_SERVER - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [88, 148.0] - rotation: 0 - state: true -- name: pdu_pdu_to_tagged_stream_0 - id: pdu_pdu_to_tagged_stream - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - tag: packet_len - type: byte - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [320, 172.0] - rotation: 0 - state: true -- name: qtgui_time_sink_x_0 - id: qtgui_time_sink_x - parameters: - affinity: '' - alias: '' - alpha1: '1.0' - alpha10: '1.0' - alpha2: '1.0' - alpha3: '1.0' - alpha4: '1.0' - alpha5: '1.0' - alpha6: '1.0' - alpha7: '1.0' - alpha8: '1.0' - alpha9: '1.0' - autoscale: 'False' - axislabels: 'True' - color1: blue - color10: dark blue - color2: red - color3: green - color4: black - color5: cyan - color6: magenta - color7: yellow - color8: dark red - color9: dark green - comment: '' - ctrlpanel: 'True' - entags: 'True' - grid: 'False' - gui_hint: '' - label1: Signal 1 - label10: Signal 10 - label2: Signal 2 - label3: Signal 3 - label4: Signal 4 - label5: Signal 5 - label6: Signal 6 - label7: Signal 7 - label8: Signal 8 - label9: Signal 9 - legend: 'True' - marker1: '-1' - marker10: '-1' - marker2: '-1' - marker3: '-1' - marker4: '-1' - marker5: '-1' - marker6: '-1' - marker7: '-1' - marker8: '-1' - marker9: '-1' - name: '"Quadrature"' - nconnections: '1' - size: '1024' - srate: samp_rate - stemplot: 'False' - style1: '1' - style10: '1' - style2: '1' - style3: '1' - style4: '1' - style5: '1' - style6: '1' - style7: '1' - style8: '1' - style9: '1' - tr_chan: '0' - tr_delay: '0' - tr_level: '0.0' - tr_mode: qtgui.TRIG_MODE_FREE - tr_slope: qtgui.TRIG_SLOPE_POS - tr_tag: '""' - type: float - update_time: '0.10' - width1: '1' - width10: '1' - width2: '1' - width3: '1' - width4: '1' - width5: '1' - width6: '1' - width7: '1' - width8: '1' - width9: '1' - ylabel: Amplitude - ymax: '1' - ymin: '-1' - yunit: '""' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [960, 292.0] - rotation: 0 - state: disabled -- name: qtgui_time_sink_x_0_0 - id: qtgui_time_sink_x - parameters: - affinity: '' - alias: '' - alpha1: '1.0' - alpha10: '1.0' - alpha2: '1.0' - alpha3: '1.0' - alpha4: '1.0' - alpha5: '1.0' - alpha6: '1.0' - alpha7: '1.0' - alpha8: '1.0' - alpha9: '1.0' - autoscale: 'False' - axislabels: 'True' - color1: blue - color10: dark blue - color2: red - color3: green - color4: black - color5: cyan - color6: magenta - color7: yellow - color8: dark red - color9: dark green - comment: '' - ctrlpanel: 'True' - entags: 'True' - grid: 'False' - gui_hint: '' - label1: Quadrature - label10: Signal 10 - label2: Amplitude - label3: Signal 3 - label4: Signal 4 - label5: Signal 5 - label6: Signal 6 - label7: Signal 7 - label8: Signal 8 - label9: Signal 9 - legend: 'True' - marker1: '-1' - marker10: '-1' - marker2: '-1' - marker3: '-1' - marker4: '-1' - marker5: '-1' - marker6: '-1' - marker7: '-1' - marker8: '-1' - marker9: '-1' - name: '"Quadrature"' - nconnections: '2' - size: '1024' - srate: samp_rate - stemplot: 'False' - style1: '1' - style10: '1' - style2: '1' - style3: '1' - style4: '1' - style5: '1' - style6: '1' - style7: '1' - style8: '1' - style9: '1' - tr_chan: '1' - tr_delay: '0' - tr_level: '0.01' - tr_mode: qtgui.TRIG_MODE_NORM - tr_slope: qtgui.TRIG_SLOPE_POS - tr_tag: '""' - type: float - update_time: '0.10' - width1: '1' - width10: '1' - width2: '1' - width3: '1' - width4: '1' - width5: '1' - width6: '1' - width7: '1' - width8: '1' - width9: '1' - ylabel: Amplitude - ymax: '1' - ymin: '-1' - yunit: '""' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [712, 292.0] - rotation: 0 - state: enabled -- name: qtgui_time_sink_x_1 - id: qtgui_time_sink_x - parameters: - affinity: '' - alias: '' - alpha1: '1.0' - alpha10: '1.0' - alpha2: '1.0' - alpha3: '1.0' - alpha4: '1.0' - alpha5: '1.0' - alpha6: '1.0' - alpha7: '1.0' - alpha8: '1.0' - alpha9: '1.0' - autoscale: 'False' - axislabels: 'True' - color1: blue - color10: dark blue - color2: red - color3: green - color4: black - color5: cyan - color6: magenta - color7: yellow - color8: dark red - color9: dark green - comment: '' - ctrlpanel: 'False' - entags: 'True' - grid: 'False' - gui_hint: '' - label1: Signal 1 - label10: Signal 10 - label2: Signal 2 - label3: Signal 3 - label4: Signal 4 - label5: Signal 5 - label6: Signal 6 - label7: Signal 7 - label8: Signal 8 - label9: Signal 9 - legend: 'True' - marker1: '-1' - marker10: '-1' - marker2: '-1' - marker3: '-1' - marker4: '-1' - marker5: '-1' - marker6: '-1' - marker7: '-1' - marker8: '-1' - marker9: '-1' - name: '""' - nconnections: '1' - size: '1024' - srate: samp_rate - stemplot: 'False' - style1: '1' - style10: '1' - style2: '1' - style3: '1' - style4: '1' - style5: '1' - style6: '1' - style7: '1' - style8: '1' - style9: '1' - tr_chan: '0' - tr_delay: '0' - tr_level: '0.0' - tr_mode: qtgui.TRIG_MODE_FREE - tr_slope: qtgui.TRIG_SLOPE_POS - tr_tag: '""' - type: complex - update_time: '0.10' - width1: '1' - width10: '1' - width2: '1' - width3: '1' - width4: '1' - width5: '1' - width6: '1' - width7: '1' - width8: '1' - width9: '1' - ylabel: Amplitude - ymax: '1' - ymin: '-1' - yunit: '""' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [1248, 300.0] - rotation: 0 - state: disabled -- name: uhd_usrp_sink_0 - id: uhd_usrp_sink - parameters: - affinity: '' - alias: '' - ant0: '"TX/RX"' - ant1: '"TX/RX"' - ant10: '"TX/RX"' - ant11: '"TX/RX"' - ant12: '"TX/RX"' - ant13: '"TX/RX"' - ant14: '"TX/RX"' - ant15: '"TX/RX"' - ant16: '"TX/RX"' - ant17: '"TX/RX"' - ant18: '"TX/RX"' - ant19: '"TX/RX"' - ant2: '"TX/RX"' - ant20: '"TX/RX"' - ant21: '"TX/RX"' - ant22: '"TX/RX"' - ant23: '"TX/RX"' - ant24: '"TX/RX"' - ant25: '"TX/RX"' - ant26: '"TX/RX"' - ant27: '"TX/RX"' - ant28: '"TX/RX"' - ant29: '"TX/RX"' - ant3: '"TX/RX"' - ant30: '"TX/RX"' - ant31: '"TX/RX"' - ant4: '"TX/RX"' - ant5: '"TX/RX"' - ant6: '"TX/RX"' - ant7: '"TX/RX"' - ant8: '"TX/RX"' - ant9: '"TX/RX"' - bw0: samp_rate - bw1: '0' - bw10: '0' - bw11: '0' - bw12: '0' - bw13: '0' - bw14: '0' - bw15: '0' - bw16: '0' - bw17: '0' - bw18: '0' - bw19: '0' - bw2: '0' - bw20: '0' - bw21: '0' - bw22: '0' - bw23: '0' - bw24: '0' - bw25: '0' - bw26: '0' - bw27: '0' - bw28: '0' - bw29: '0' - bw3: '0' - bw30: '0' - bw31: '0' - bw4: '0' - bw5: '0' - bw6: '0' - bw7: '0' - bw8: '0' - bw9: '0' - center_freq0: f - center_freq1: '0' - center_freq10: '0' - center_freq11: '0' - center_freq12: '0' - center_freq13: '0' - center_freq14: '0' - center_freq15: '0' - center_freq16: '0' - center_freq17: '0' - center_freq18: '0' - center_freq19: '0' - center_freq2: '0' - center_freq20: '0' - center_freq21: '0' - center_freq22: '0' - center_freq23: '0' - center_freq24: '0' - center_freq25: '0' - center_freq26: '0' - center_freq27: '0' - center_freq28: '0' - center_freq29: '0' - center_freq3: '0' - center_freq30: '0' - center_freq31: '0' - center_freq4: '0' - center_freq5: '0' - center_freq6: '0' - center_freq7: '0' - center_freq8: '0' - center_freq9: '0' - clock_rate: 0e0 - clock_source0: '' - clock_source1: '' - clock_source2: '' - clock_source3: '' - clock_source4: '' - clock_source5: '' - clock_source6: '' - clock_source7: '' - comment: '' - dev_addr: '""' - dev_args: '' - gain0: gain - gain1: '0' - gain10: '0' - gain11: '0' - gain12: '0' - gain13: '0' - gain14: '0' - gain15: '0' - gain16: '0' - gain17: '0' - gain18: '0' - gain19: '0' - gain2: '0' - gain20: '0' - gain21: '0' - gain22: '0' - gain23: '0' - gain24: '0' - gain25: '0' - gain26: '0' - gain27: '0' - gain28: '0' - gain29: '0' - gain3: '0' - gain30: '0' - gain31: '0' - gain4: '0' - gain5: '0' - gain6: '0' - gain7: '0' - gain8: '0' - gain9: '0' - gain_type0: default - gain_type1: default - gain_type10: default - gain_type11: default - gain_type12: default - gain_type13: default - gain_type14: default - gain_type15: default - gain_type16: default - gain_type17: default - gain_type18: default - gain_type19: default - gain_type2: default - gain_type20: default - gain_type21: default - gain_type22: default - gain_type23: default - gain_type24: default - gain_type25: default - gain_type26: default - gain_type27: default - gain_type28: default - gain_type29: default - gain_type3: default - gain_type30: default - gain_type31: default - gain_type4: default - gain_type5: default - gain_type6: default - gain_type7: default - gain_type8: default - gain_type9: default - len_tag_name: '""' - lo_export0: 'False' - lo_export1: 'False' - lo_export10: 'False' - lo_export11: 'False' - lo_export12: 'False' - lo_export13: 'False' - lo_export14: 'False' - lo_export15: 'False' - lo_export16: 'False' - lo_export17: 'False' - lo_export18: 'False' - lo_export19: 'False' - lo_export2: 'False' - lo_export20: 'False' - lo_export21: 'False' - lo_export22: 'False' - lo_export23: 'False' - lo_export24: 'False' - lo_export25: 'False' - lo_export26: 'False' - lo_export27: 'False' - lo_export28: 'False' - lo_export29: 'False' - lo_export3: 'False' - lo_export30: 'False' - lo_export31: 'False' - lo_export4: 'False' - lo_export5: 'False' - lo_export6: 'False' - lo_export7: 'False' - lo_export8: 'False' - lo_export9: 'False' - lo_source0: internal - lo_source1: internal - lo_source10: internal - lo_source11: internal - lo_source12: internal - lo_source13: internal - lo_source14: internal - lo_source15: internal - lo_source16: internal - lo_source17: internal - lo_source18: internal - lo_source19: internal - lo_source2: internal - lo_source20: internal - lo_source21: internal - lo_source22: internal - lo_source23: internal - lo_source24: internal - lo_source25: internal - lo_source26: internal - lo_source27: internal - lo_source28: internal - lo_source29: internal - lo_source3: internal - lo_source30: internal - lo_source31: internal - lo_source4: internal - lo_source5: internal - lo_source6: internal - lo_source7: internal - lo_source8: internal - lo_source9: internal - maxoutbuf: '0' - minoutbuf: '0' - nchan: '1' - num_mboards: '1' - otw: '' - samp_rate: samp_rate - sd_spec0: '' - sd_spec1: '' - sd_spec2: '' - sd_spec3: '' - sd_spec4: '' - sd_spec5: '' - sd_spec6: '' - sd_spec7: '' - show_lo_controls: 'False' - start_time: '-1.0' - stream_args: '' - stream_chans: '[]' - sync: sync - time_source0: '' - time_source1: '' - time_source2: '' - time_source3: '' - time_source4: '' - time_source5: '' - time_source6: '' - time_source7: '' - type: fc32 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [1416, 116.0] - rotation: 0 - state: true -- name: uhd_usrp_source_0 - id: uhd_usrp_source - parameters: - affinity: '' - alias: '' - ant0: RX2 - ant1: RX2 - ant10: RX2 - ant11: RX2 - ant12: RX2 - ant13: RX2 - ant14: RX2 - ant15: RX2 - ant16: RX2 - ant17: RX2 - ant18: RX2 - ant19: RX2 - ant2: RX2 - ant20: RX2 - ant21: RX2 - ant22: RX2 - ant23: RX2 - ant24: RX2 - ant25: RX2 - ant26: RX2 - ant27: RX2 - ant28: RX2 - ant29: RX2 - ant3: RX2 - ant30: RX2 - ant31: RX2 - ant4: RX2 - ant5: RX2 - ant6: RX2 - ant7: RX2 - ant8: RX2 - ant9: RX2 - bw0: samp_rate - bw1: '0' - bw10: '0' - bw11: '0' - bw12: '0' - bw13: '0' - bw14: '0' - bw15: '0' - bw16: '0' - bw17: '0' - bw18: '0' - bw19: '0' - bw2: '0' - bw20: '0' - bw21: '0' - bw22: '0' - bw23: '0' - bw24: '0' - bw25: '0' - bw26: '0' - bw27: '0' - bw28: '0' - bw29: '0' - bw3: '0' - bw30: '0' - bw31: '0' - bw4: '0' - bw5: '0' - bw6: '0' - bw7: '0' - bw8: '0' - bw9: '0' - center_freq0: f - center_freq1: '0' - center_freq10: '0' - center_freq11: '0' - center_freq12: '0' - center_freq13: '0' - center_freq14: '0' - center_freq15: '0' - center_freq16: '0' - center_freq17: '0' - center_freq18: '0' - center_freq19: '0' - center_freq2: '0' - center_freq20: '0' - center_freq21: '0' - center_freq22: '0' - center_freq23: '0' - center_freq24: '0' - center_freq25: '0' - center_freq26: '0' - center_freq27: '0' - center_freq28: '0' - center_freq29: '0' - center_freq3: '0' - center_freq30: '0' - center_freq31: '0' - center_freq4: '0' - center_freq5: '0' - center_freq6: '0' - center_freq7: '0' - center_freq8: '0' - center_freq9: '0' - clock_rate: 0e0 - clock_source0: '' - clock_source1: '' - clock_source2: '' - clock_source3: '' - clock_source4: '' - clock_source5: '' - clock_source6: '' - clock_source7: '' - comment: '' - dc_offs0: 0+0j - dc_offs1: 0+0j - dc_offs10: 0+0j - dc_offs11: 0+0j - dc_offs12: 0+0j - dc_offs13: 0+0j - dc_offs14: 0+0j - dc_offs15: 0+0j - dc_offs16: 0+0j - dc_offs17: 0+0j - dc_offs18: 0+0j - dc_offs19: 0+0j - dc_offs2: 0+0j - dc_offs20: 0+0j - dc_offs21: 0+0j - dc_offs22: 0+0j - dc_offs23: 0+0j - dc_offs24: 0+0j - dc_offs25: 0+0j - dc_offs26: 0+0j - dc_offs27: 0+0j - dc_offs28: 0+0j - dc_offs29: 0+0j - dc_offs3: 0+0j - dc_offs30: 0+0j - dc_offs31: 0+0j - dc_offs4: 0+0j - dc_offs5: 0+0j - dc_offs6: 0+0j - dc_offs7: 0+0j - dc_offs8: 0+0j - dc_offs9: 0+0j - dc_offs_enb0: default - dc_offs_enb1: default - dc_offs_enb10: default - dc_offs_enb11: default - dc_offs_enb12: default - dc_offs_enb13: default - dc_offs_enb14: default - dc_offs_enb15: default - dc_offs_enb16: default - dc_offs_enb17: default - dc_offs_enb18: default - dc_offs_enb19: default - dc_offs_enb2: default - dc_offs_enb20: default - dc_offs_enb21: default - dc_offs_enb22: default - dc_offs_enb23: default - dc_offs_enb24: default - dc_offs_enb25: default - dc_offs_enb26: default - dc_offs_enb27: default - dc_offs_enb28: default - dc_offs_enb29: default - dc_offs_enb3: default - dc_offs_enb30: default - dc_offs_enb31: default - dc_offs_enb4: default - dc_offs_enb5: default - dc_offs_enb6: default - dc_offs_enb7: default - dc_offs_enb8: default - dc_offs_enb9: default - dev_addr: '""' - dev_args: '""' - gain0: '40' - gain1: '0' - gain10: '0' - gain11: '0' - gain12: '0' - gain13: '0' - gain14: '0' - gain15: '0' - gain16: '0' - gain17: '0' - gain18: '0' - gain19: '0' - gain2: '0' - gain20: '0' - gain21: '0' - gain22: '0' - gain23: '0' - gain24: '0' - gain25: '0' - gain26: '0' - gain27: '0' - gain28: '0' - gain29: '0' - gain3: '0' - gain30: '0' - gain31: '0' - gain4: '0' - gain5: '0' - gain6: '0' - gain7: '0' - gain8: '0' - gain9: '0' - gain_type0: default - gain_type1: default - gain_type10: default - gain_type11: default - gain_type12: default - gain_type13: default - gain_type14: default - gain_type15: default - gain_type16: default - gain_type17: default - gain_type18: default - gain_type19: default - gain_type2: default - gain_type20: default - gain_type21: default - gain_type22: default - gain_type23: default - gain_type24: default - gain_type25: default - gain_type26: default - gain_type27: default - gain_type28: default - gain_type29: default - gain_type3: default - gain_type30: default - gain_type31: default - gain_type4: default - gain_type5: default - gain_type6: default - gain_type7: default - gain_type8: default - gain_type9: default - iq_imbal0: 0+0j - iq_imbal1: 0+0j - iq_imbal10: 0+0j - iq_imbal11: 0+0j - iq_imbal12: 0+0j - iq_imbal13: 0+0j - iq_imbal14: 0+0j - iq_imbal15: 0+0j - iq_imbal16: 0+0j - iq_imbal17: 0+0j - iq_imbal18: 0+0j - iq_imbal19: 0+0j - iq_imbal2: 0+0j - iq_imbal20: 0+0j - iq_imbal21: 0+0j - iq_imbal22: 0+0j - iq_imbal23: 0+0j - iq_imbal24: 0+0j - iq_imbal25: 0+0j - iq_imbal26: 0+0j - iq_imbal27: 0+0j - iq_imbal28: 0+0j - iq_imbal29: 0+0j - iq_imbal3: 0+0j - iq_imbal30: 0+0j - iq_imbal31: 0+0j - iq_imbal4: 0+0j - iq_imbal5: 0+0j - iq_imbal6: 0+0j - iq_imbal7: 0+0j - iq_imbal8: 0+0j - iq_imbal9: 0+0j - iq_imbal_enb0: default - iq_imbal_enb1: default - iq_imbal_enb10: default - iq_imbal_enb11: default - iq_imbal_enb12: default - iq_imbal_enb13: default - iq_imbal_enb14: default - iq_imbal_enb15: default - iq_imbal_enb16: default - iq_imbal_enb17: default - iq_imbal_enb18: default - iq_imbal_enb19: default - iq_imbal_enb2: default - iq_imbal_enb20: default - iq_imbal_enb21: default - iq_imbal_enb22: default - iq_imbal_enb23: default - iq_imbal_enb24: default - iq_imbal_enb25: default - iq_imbal_enb26: default - iq_imbal_enb27: default - iq_imbal_enb28: default - iq_imbal_enb29: default - iq_imbal_enb3: default - iq_imbal_enb30: default - iq_imbal_enb31: default - iq_imbal_enb4: default - iq_imbal_enb5: default - iq_imbal_enb6: default - iq_imbal_enb7: default - iq_imbal_enb8: default - iq_imbal_enb9: default - lo_export0: 'False' - lo_export1: 'False' - lo_export10: 'False' - lo_export11: 'False' - lo_export12: 'False' - lo_export13: 'False' - lo_export14: 'False' - lo_export15: 'False' - lo_export16: 'False' - lo_export17: 'False' - lo_export18: 'False' - lo_export19: 'False' - lo_export2: 'False' - lo_export20: 'False' - lo_export21: 'False' - lo_export22: 'False' - lo_export23: 'False' - lo_export24: 'False' - lo_export25: 'False' - lo_export26: 'False' - lo_export27: 'False' - lo_export28: 'False' - lo_export29: 'False' - lo_export3: 'False' - lo_export30: 'False' - lo_export31: 'False' - lo_export4: 'False' - lo_export5: 'False' - lo_export6: 'False' - lo_export7: 'False' - lo_export8: 'False' - lo_export9: 'False' - lo_source0: internal - lo_source1: internal - lo_source10: internal - lo_source11: internal - lo_source12: internal - lo_source13: internal - lo_source14: internal - lo_source15: internal - lo_source16: internal - lo_source17: internal - lo_source18: internal - lo_source19: internal - lo_source2: internal - lo_source20: internal - lo_source21: internal - lo_source22: internal - lo_source23: internal - lo_source24: internal - lo_source25: internal - lo_source26: internal - lo_source27: internal - lo_source28: internal - lo_source29: internal - lo_source3: internal - lo_source30: internal - lo_source31: internal - lo_source4: internal - lo_source5: internal - lo_source6: internal - lo_source7: internal - lo_source8: internal - lo_source9: internal - maxoutbuf: '0' - minoutbuf: '0' - nchan: '1' - num_mboards: '1' - otw: '' - rx_agc0: Disabled - rx_agc1: Default - rx_agc10: Default - rx_agc11: Default - rx_agc12: Default - rx_agc13: Default - rx_agc14: Default - rx_agc15: Default - rx_agc16: Default - rx_agc17: Default - rx_agc18: Default - rx_agc19: Default - rx_agc2: Default - rx_agc20: Default - rx_agc21: Default - rx_agc22: Default - rx_agc23: Default - rx_agc24: Default - rx_agc25: Default - rx_agc26: Default - rx_agc27: Default - rx_agc28: Default - rx_agc29: Default - rx_agc3: Default - rx_agc30: Default - rx_agc31: Default - rx_agc4: Default - rx_agc5: Default - rx_agc6: Default - rx_agc7: Default - rx_agc8: Default - rx_agc9: Default - samp_rate: samp_rate - sd_spec0: '' - sd_spec1: '' - sd_spec2: '' - sd_spec3: '' - sd_spec4: '' - sd_spec5: '' - sd_spec6: '' - sd_spec7: '' - show_lo_controls: 'False' - start_time: '-1.0' - stream_args: '' - stream_chans: '[]' - sync: sync - time_source0: '' - time_source1: '' - time_source2: '' - time_source3: '' - time_source4: '' - time_source5: '' - time_source6: '' - time_source7: '' - type: fc32 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [72, 364.0] - rotation: 0 - state: enabled - -connections: -- [analog_frequency_modulator_fc_0, '0', low_pass_filter_0, '0'] -- [analog_quadrature_demod_cf_0_0, '0', blocks_float_to_complex_0, '0'] -- [analog_quadrature_demod_cf_0_0, '0', qtgui_time_sink_x_0_0, '0'] -- [blocks_add_const_vxx_0, '0', blocks_repeat_0, '0'] -- [blocks_char_to_float_0, '0', blocks_add_const_vxx_0, '0'] -- [blocks_complex_to_mag_0, '0', blocks_float_to_complex_0, '1'] -- [blocks_complex_to_mag_0, '0', qtgui_time_sink_x_0_0, '1'] -- [blocks_float_to_complex_0, '0', blocks_file_sink_0_0, '0'] -- [blocks_float_to_complex_0, '0', blocks_null_sink_0, '0'] -- [blocks_repeat_0, '0', analog_frequency_modulator_fc_0, '0'] -- [blocks_repeat_0, '0', qtgui_time_sink_x_0, '0'] -- [blocks_unpack_k_bits_bb_0, '0', blocks_char_to_float_0, '0'] -- [low_pass_filter_0, '0', qtgui_time_sink_x_1, '0'] -- [low_pass_filter_0, '0', uhd_usrp_sink_0, '0'] -- [network_socket_pdu_0, pdus, pdu_pdu_to_tagged_stream_0, pdus] -- [pdu_pdu_to_tagged_stream_0, '0', blocks_unpack_k_bits_bb_0, '0'] -- [uhd_usrp_source_0, '0', analog_quadrature_demod_cf_0_0, '0'] -- [uhd_usrp_source_0, '0', blocks_complex_to_mag_0, '0'] -- [uhd_usrp_source_0, '0', fosphor_qt_sink_c_0_0, '0'] - -metadata: - file_format: 1 - grc_version: 3.10.2.0 diff --git a/components/spi-cc1200/sdr/cc1200_tx.grc b/components/spi-cc1200/sdr/cc1200_tx.grc deleted file mode 100644 index 8a5c90f..0000000 --- a/components/spi-cc1200/sdr/cc1200_tx.grc +++ /dev/null @@ -1,1395 +0,0 @@ -options: - parameters: - author: hammel - catch_exceptions: 'True' - category: '[GRC Hier Blocks]' - cmake_opt: '' - comment: '' - copyright: '' - description: '' - gen_cmake: 'On' - gen_linking: dynamic - generate_options: qt_gui - hier_block_src_path: '.:' - id: cc1200_tx - max_nouts: '0' - output_language: python - placement: (0,0) - qt_qss_theme: '' - realtime_scheduling: '' - run: 'True' - run_command: '{python} -u {filename}' - run_options: prompt - sizing_mode: fixed - thread_safe_setters: '' - title: Not titled yet - window_size: (1000,1000) - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [8, 8] - rotation: 0 - state: enabled - -blocks: -- name: bit_rate - id: variable - parameters: - comment: '' - value: '1200' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [472, 12.0] - rotation: 0 - state: enabled -- name: deviation - id: variable - parameters: - comment: '' - value: 3e3 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [280, 12.0] - rotation: 0 - state: enabled -- name: f - id: variable - parameters: - comment: '' - value: 868e6 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [368, 12.0] - rotation: 0 - state: enabled -- name: foff - id: variable - parameters: - comment: '' - value: samp_rate/4 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [560, 12.0] - rotation: 0 - state: enabled -- name: samp_rate - id: variable - parameters: - comment: '' - value: 12e5 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [184, 12] - rotation: 0 - state: enabled -- name: analog_frequency_modulator_fc_0_0 - id: analog_frequency_modulator_fc - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - sensitivity: 2*3.14159*(deviation/samp_rate) - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [448, 468.0] - rotation: 0 - state: enabled -- name: analog_quadrature_demod_cf_0_0 - id: analog_quadrature_demod_cf - parameters: - affinity: '' - alias: '' - comment: '' - gain: 1/math.pi - maxoutbuf: '0' - minoutbuf: '0' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [400, 900.0] - rotation: 0 - state: disabled -- name: analog_sig_source_x_0_0 - id: analog_sig_source_x - parameters: - affinity: '' - alias: '' - amp: '1' - comment: '' - freq: foff - maxoutbuf: '0' - minoutbuf: '0' - offset: '0' - phase: '0' - samp_rate: samp_rate - type: complex - waveform: analog.GR_COS_WAVE - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [888, 644.0] - rotation: 0 - state: enabled -- name: blocks_add_const_vxx_0 - id: blocks_add_const_vxx - parameters: - affinity: '' - alias: '' - comment: '' - const: '-1' - maxoutbuf: '0' - minoutbuf: '0' - type: float - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [888, 172.0] - rotation: 0 - state: disabled -- name: blocks_char_to_float_0 - id: blocks_char_to_float - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - scale: '2' - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [712, 172.0] - rotation: 0 - state: disabled -- name: blocks_char_to_float_0_0 - id: blocks_char_to_float - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - scale: '1' - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [552, 300.0] - rotation: 0 - state: enabled -- name: blocks_complex_to_mag_0 - id: blocks_complex_to_mag - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [408, 960.0] - rotation: 0 - state: disabled -- name: blocks_file_sink_0_0 - id: blocks_file_sink - parameters: - affinity: '' - alias: '' - append: 'False' - comment: '' - file: /tmp/demod.fifo - type: complex - unbuffered: 'False' - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [944, 1036.0] - rotation: 0 - state: disabled -- name: blocks_float_to_complex_0 - id: blocks_float_to_complex - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [696, 1040.0] - rotation: 0 - state: disabled -- name: blocks_float_to_complex_1 - id: blocks_float_to_complex - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [456, 536.0] - rotation: 0 - state: enabled -- name: blocks_multiply_xx_0 - id: blocks_multiply_xx - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - num_inputs: '2' - type: complex - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [688, 496.0] - rotation: 0 - state: enabled -- name: blocks_multiply_xx_0_0 - id: blocks_multiply_xx - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - num_inputs: '2' - type: complex - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [1152, 512.0] - rotation: 0 - state: enabled -- name: blocks_null_sink_0 - id: blocks_null_sink - parameters: - affinity: '' - alias: '' - bus_structure_sink: '[[0,],]' - comment: '' - num_inputs: '1' - type: complex - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [944, 1144.0] - rotation: 0 - state: disabled -- name: blocks_null_source_0 - id: blocks_null_source - parameters: - affinity: '' - alias: '' - bus_structure_source: '[[0,],]' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - num_outputs: '1' - type: float - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [296, 568.0] - rotation: 0 - state: enabled -- name: blocks_repeat_0_0 - id: blocks_repeat - parameters: - affinity: '' - alias: '' - comment: '' - interp: int(samp_rate / bit_rate) - maxoutbuf: '0' - minoutbuf: '0' - type: float - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [224, 468.0] - rotation: 0 - state: enabled -- name: blocks_unpack_k_bits_bb_0 - id: blocks_unpack_k_bits_bb - parameters: - affinity: '' - alias: '' - comment: '' - k: '8' - maxoutbuf: '0' - minoutbuf: '0' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [536, 172.0] - rotation: 0 - state: disabled -- name: fosphor_qt_sink_c_0_0 - id: fosphor_qt_sink_c - parameters: - affinity: '' - alias: '' - comment: '' - freq_center: f - freq_span: samp_rate - gui_hint: '' - maxoutbuf: '0' - minoutbuf: '0' - wintype: window.WIN_BLACKMAN_hARRIS - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [376, 1020.0] - rotation: 0 - state: disabled -- name: fosphor_qt_sink_c_0_0_0 - id: fosphor_qt_sink_c - parameters: - affinity: '' - alias: '' - comment: '' - freq_center: f-foff - freq_span: samp_rate - gui_hint: '' - maxoutbuf: '0' - minoutbuf: '0' - wintype: window.WIN_BLACKMAN_hARRIS - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [1320, 652.0] - rotation: 0 - state: enabled -- name: low_pass_filter_0 - id: low_pass_filter - parameters: - affinity: '' - alias: '' - beta: '6.76' - comment: '' - cutoff_freq: deviation *2 - decim: '1' - gain: '1' - interp: '1' - maxoutbuf: '0' - minoutbuf: '0' - samp_rate: samp_rate - type: fir_filter_ccf - width: 'deviation ' - win: window.WIN_HAMMING - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [848, 460.0] - rotation: 0 - state: enabled -- name: network_socket_pdu_0 - id: network_socket_pdu - parameters: - affinity: '' - alias: '' - comment: '' - host: '' - maxoutbuf: '0' - minoutbuf: '0' - mtu: '10000' - port: '52001' - tcp_no_delay: 'True' - type: UDP_SERVER - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [88, 148.0] - rotation: 0 - state: disabled -- name: network_socket_pdu_0_0 - id: network_socket_pdu - parameters: - affinity: '' - alias: '' - comment: '' - host: '' - maxoutbuf: '0' - minoutbuf: '0' - mtu: '10000' - port: '1234' - tcp_no_delay: 'True' - type: UDP_SERVER - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [88, 276.0] - rotation: 0 - state: enabled -- name: osmosdr_sink_0_0 - id: osmosdr_sink - parameters: - affinity: '' - alias: '' - ant0: '' - ant1: '' - ant10: '' - ant11: '' - ant12: '' - ant13: '' - ant14: '' - ant15: '' - ant16: '' - ant17: '' - ant18: '' - ant19: '' - ant2: '' - ant20: '' - ant21: '' - ant22: '' - ant23: '' - ant24: '' - ant25: '' - ant26: '' - ant27: '' - ant28: '' - ant29: '' - ant3: '' - ant30: '' - ant31: '' - ant4: '' - ant5: '' - ant6: '' - ant7: '' - ant8: '' - ant9: '' - args: '""' - bb_gain0: '89.9' - bb_gain1: '20' - bb_gain10: '20' - bb_gain11: '20' - bb_gain12: '20' - bb_gain13: '20' - bb_gain14: '20' - bb_gain15: '20' - bb_gain16: '20' - bb_gain17: '20' - bb_gain18: '20' - bb_gain19: '20' - bb_gain2: '20' - bb_gain20: '20' - bb_gain21: '20' - bb_gain22: '20' - bb_gain23: '20' - bb_gain24: '20' - bb_gain25: '20' - bb_gain26: '20' - bb_gain27: '20' - bb_gain28: '20' - bb_gain29: '20' - bb_gain3: '20' - bb_gain30: '20' - bb_gain31: '20' - bb_gain4: '20' - bb_gain5: '20' - bb_gain6: '20' - bb_gain7: '20' - bb_gain8: '20' - bb_gain9: '20' - bw0: samp_rate - bw1: '0' - bw10: '0' - bw11: '0' - bw12: '0' - bw13: '0' - bw14: '0' - bw15: '0' - bw16: '0' - bw17: '0' - bw18: '0' - bw19: '0' - bw2: '0' - bw20: '0' - bw21: '0' - bw22: '0' - bw23: '0' - bw24: '0' - bw25: '0' - bw26: '0' - bw27: '0' - bw28: '0' - bw29: '0' - bw3: '0' - bw30: '0' - bw31: '0' - bw4: '0' - bw5: '0' - bw6: '0' - bw7: '0' - bw8: '0' - bw9: '0' - clock_source0: '' - clock_source1: '' - clock_source2: '' - clock_source3: '' - clock_source4: '' - clock_source5: '' - clock_source6: '' - clock_source7: '' - comment: '' - corr0: '0' - corr1: '0' - corr10: '0' - corr11: '0' - corr12: '0' - corr13: '0' - corr14: '0' - corr15: '0' - corr16: '0' - corr17: '0' - corr18: '0' - corr19: '0' - corr2: '0' - corr20: '0' - corr21: '0' - corr22: '0' - corr23: '0' - corr24: '0' - corr25: '0' - corr26: '0' - corr27: '0' - corr28: '0' - corr29: '0' - corr3: '0' - corr30: '0' - corr31: '0' - corr4: '0' - corr5: '0' - corr6: '0' - corr7: '0' - corr8: '0' - corr9: '0' - freq0: f-foff - freq1: 100e6 - freq10: 100e6 - freq11: 100e6 - freq12: 100e6 - freq13: 100e6 - freq14: 100e6 - freq15: 100e6 - freq16: 100e6 - freq17: 100e6 - freq18: 100e6 - freq19: 100e6 - freq2: 100e6 - freq20: 100e6 - freq21: 100e6 - freq22: 100e6 - freq23: 100e6 - freq24: 100e6 - freq25: 100e6 - freq26: 100e6 - freq27: 100e6 - freq28: 100e6 - freq29: 100e6 - freq3: 100e6 - freq30: 100e6 - freq31: 100e6 - freq4: 100e6 - freq5: 100e6 - freq6: 100e6 - freq7: 100e6 - freq8: 100e6 - freq9: 100e6 - gain0: '89.9' - gain1: '10' - gain10: '10' - gain11: '10' - gain12: '10' - gain13: '10' - gain14: '10' - gain15: '10' - gain16: '10' - gain17: '10' - gain18: '10' - gain19: '10' - gain2: '10' - gain20: '10' - gain21: '10' - gain22: '10' - gain23: '10' - gain24: '10' - gain25: '10' - gain26: '10' - gain27: '10' - gain28: '10' - gain29: '10' - gain3: '10' - gain30: '10' - gain31: '10' - gain4: '10' - gain5: '10' - gain6: '10' - gain7: '10' - gain8: '10' - gain9: '10' - if_gain0: '89.9' - if_gain1: '20' - if_gain10: '20' - if_gain11: '20' - if_gain12: '20' - if_gain13: '20' - if_gain14: '20' - if_gain15: '20' - if_gain16: '20' - if_gain17: '20' - if_gain18: '20' - if_gain19: '20' - if_gain2: '20' - if_gain20: '20' - if_gain21: '20' - if_gain22: '20' - if_gain23: '20' - if_gain24: '20' - if_gain25: '20' - if_gain26: '20' - if_gain27: '20' - if_gain28: '20' - if_gain29: '20' - if_gain3: '20' - if_gain30: '20' - if_gain31: '20' - if_gain4: '20' - if_gain5: '20' - if_gain6: '20' - if_gain7: '20' - if_gain8: '20' - if_gain9: '20' - maxoutbuf: '0' - minoutbuf: '0' - nchan: '1' - num_mboards: '1' - sample_rate: samp_rate - sync: sync - time_source0: '' - time_source1: '' - time_source2: '' - time_source3: '' - time_source4: '' - time_source5: '' - time_source6: '' - time_source7: '' - type: fc32 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [1368, 380.0] - rotation: 0 - state: enabled -- name: osmosdr_source_0 - id: osmosdr_source - parameters: - affinity: '' - alias: '' - ant0: '' - ant1: '' - ant10: '' - ant11: '' - ant12: '' - ant13: '' - ant14: '' - ant15: '' - ant16: '' - ant17: '' - ant18: '' - ant19: '' - ant2: '' - ant20: '' - ant21: '' - ant22: '' - ant23: '' - ant24: '' - ant25: '' - ant26: '' - ant27: '' - ant28: '' - ant29: '' - ant3: '' - ant30: '' - ant31: '' - ant4: '' - ant5: '' - ant6: '' - ant7: '' - ant8: '' - ant9: '' - args: '""' - bb_gain0: '10' - bb_gain1: '20' - bb_gain10: '20' - bb_gain11: '20' - bb_gain12: '20' - bb_gain13: '20' - bb_gain14: '20' - bb_gain15: '20' - bb_gain16: '20' - bb_gain17: '20' - bb_gain18: '20' - bb_gain19: '20' - bb_gain2: '20' - bb_gain20: '20' - bb_gain21: '20' - bb_gain22: '20' - bb_gain23: '20' - bb_gain24: '20' - bb_gain25: '20' - bb_gain26: '20' - bb_gain27: '20' - bb_gain28: '20' - bb_gain29: '20' - bb_gain3: '20' - bb_gain30: '20' - bb_gain31: '20' - bb_gain4: '20' - bb_gain5: '20' - bb_gain6: '20' - bb_gain7: '20' - bb_gain8: '20' - bb_gain9: '20' - bw0: samp_rate - bw1: '0' - bw10: '0' - bw11: '0' - bw12: '0' - bw13: '0' - bw14: '0' - bw15: '0' - bw16: '0' - bw17: '0' - bw18: '0' - bw19: '0' - bw2: '0' - bw20: '0' - bw21: '0' - bw22: '0' - bw23: '0' - bw24: '0' - bw25: '0' - bw26: '0' - bw27: '0' - bw28: '0' - bw29: '0' - bw3: '0' - bw30: '0' - bw31: '0' - bw4: '0' - bw5: '0' - bw6: '0' - bw7: '0' - bw8: '0' - bw9: '0' - clock_source0: '' - clock_source1: '' - clock_source2: '' - clock_source3: '' - clock_source4: '' - clock_source5: '' - clock_source6: '' - clock_source7: '' - comment: '' - corr0: '0' - corr1: '0' - corr10: '0' - corr11: '0' - corr12: '0' - corr13: '0' - corr14: '0' - corr15: '0' - corr16: '0' - corr17: '0' - corr18: '0' - corr19: '0' - corr2: '0' - corr20: '0' - corr21: '0' - corr22: '0' - corr23: '0' - corr24: '0' - corr25: '0' - corr26: '0' - corr27: '0' - corr28: '0' - corr29: '0' - corr3: '0' - corr30: '0' - corr31: '0' - corr4: '0' - corr5: '0' - corr6: '0' - corr7: '0' - corr8: '0' - corr9: '0' - dc_offset_mode0: '2' - dc_offset_mode1: '0' - dc_offset_mode10: '0' - dc_offset_mode11: '0' - dc_offset_mode12: '0' - dc_offset_mode13: '0' - dc_offset_mode14: '0' - dc_offset_mode15: '0' - dc_offset_mode16: '0' - dc_offset_mode17: '0' - dc_offset_mode18: '0' - dc_offset_mode19: '0' - dc_offset_mode2: '0' - dc_offset_mode20: '0' - dc_offset_mode21: '0' - dc_offset_mode22: '0' - dc_offset_mode23: '0' - dc_offset_mode24: '0' - dc_offset_mode25: '0' - dc_offset_mode26: '0' - dc_offset_mode27: '0' - dc_offset_mode28: '0' - dc_offset_mode29: '0' - dc_offset_mode3: '0' - dc_offset_mode30: '0' - dc_offset_mode31: '0' - dc_offset_mode4: '0' - dc_offset_mode5: '0' - dc_offset_mode6: '0' - dc_offset_mode7: '0' - dc_offset_mode8: '0' - dc_offset_mode9: '0' - freq0: f-foff - freq1: 100e6 - freq10: 100e6 - freq11: 100e6 - freq12: 100e6 - freq13: 100e6 - freq14: 100e6 - freq15: 100e6 - freq16: 100e6 - freq17: 100e6 - freq18: 100e6 - freq19: 100e6 - freq2: 100e6 - freq20: 100e6 - freq21: 100e6 - freq22: 100e6 - freq23: 100e6 - freq24: 100e6 - freq25: 100e6 - freq26: 100e6 - freq27: 100e6 - freq28: 100e6 - freq29: 100e6 - freq3: 100e6 - freq30: 100e6 - freq31: 100e6 - freq4: 100e6 - freq5: 100e6 - freq6: 100e6 - freq7: 100e6 - freq8: 100e6 - freq9: 100e6 - gain0: '30' - gain1: '10' - gain10: '10' - gain11: '10' - gain12: '10' - gain13: '10' - gain14: '10' - gain15: '10' - gain16: '10' - gain17: '10' - gain18: '10' - gain19: '10' - gain2: '10' - gain20: '10' - gain21: '10' - gain22: '10' - gain23: '10' - gain24: '10' - gain25: '10' - gain26: '10' - gain27: '10' - gain28: '10' - gain29: '10' - gain3: '10' - gain30: '10' - gain31: '10' - gain4: '10' - gain5: '10' - gain6: '10' - gain7: '10' - gain8: '10' - gain9: '10' - gain_mode0: 'False' - gain_mode1: 'False' - gain_mode10: 'False' - gain_mode11: 'False' - gain_mode12: 'False' - gain_mode13: 'False' - gain_mode14: 'False' - gain_mode15: 'False' - gain_mode16: 'False' - gain_mode17: 'False' - gain_mode18: 'False' - gain_mode19: 'False' - gain_mode2: 'False' - gain_mode20: 'False' - gain_mode21: 'False' - gain_mode22: 'False' - gain_mode23: 'False' - gain_mode24: 'False' - gain_mode25: 'False' - gain_mode26: 'False' - gain_mode27: 'False' - gain_mode28: 'False' - gain_mode29: 'False' - gain_mode3: 'False' - gain_mode30: 'False' - gain_mode31: 'False' - gain_mode4: 'False' - gain_mode5: 'False' - gain_mode6: 'False' - gain_mode7: 'False' - gain_mode8: 'False' - gain_mode9: 'False' - if_gain0: '10' - if_gain1: '20' - if_gain10: '20' - if_gain11: '20' - if_gain12: '20' - if_gain13: '20' - if_gain14: '20' - if_gain15: '20' - if_gain16: '20' - if_gain17: '20' - if_gain18: '20' - if_gain19: '20' - if_gain2: '20' - if_gain20: '20' - if_gain21: '20' - if_gain22: '20' - if_gain23: '20' - if_gain24: '20' - if_gain25: '20' - if_gain26: '20' - if_gain27: '20' - if_gain28: '20' - if_gain29: '20' - if_gain3: '20' - if_gain30: '20' - if_gain31: '20' - if_gain4: '20' - if_gain5: '20' - if_gain6: '20' - if_gain7: '20' - if_gain8: '20' - if_gain9: '20' - iq_balance_mode0: '2' - iq_balance_mode1: '0' - iq_balance_mode10: '0' - iq_balance_mode11: '0' - iq_balance_mode12: '0' - iq_balance_mode13: '0' - iq_balance_mode14: '0' - iq_balance_mode15: '0' - iq_balance_mode16: '0' - iq_balance_mode17: '0' - iq_balance_mode18: '0' - iq_balance_mode19: '0' - iq_balance_mode2: '0' - iq_balance_mode20: '0' - iq_balance_mode21: '0' - iq_balance_mode22: '0' - iq_balance_mode23: '0' - iq_balance_mode24: '0' - iq_balance_mode25: '0' - iq_balance_mode26: '0' - iq_balance_mode27: '0' - iq_balance_mode28: '0' - iq_balance_mode29: '0' - iq_balance_mode3: '0' - iq_balance_mode30: '0' - iq_balance_mode31: '0' - iq_balance_mode4: '0' - iq_balance_mode5: '0' - iq_balance_mode6: '0' - iq_balance_mode7: '0' - iq_balance_mode8: '0' - iq_balance_mode9: '0' - maxoutbuf: '0' - minoutbuf: '0' - nchan: '1' - num_mboards: '1' - sample_rate: samp_rate - sync: sync - time_source0: '' - time_source1: '' - time_source2: '' - time_source3: '' - time_source4: '' - time_source5: '' - time_source6: '' - time_source7: '' - type: fc32 - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [0, 820.0] - rotation: 0 - state: disabled -- name: pdu_pdu_to_tagged_stream_0 - id: pdu_pdu_to_tagged_stream - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - tag: packet_len - type: byte - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [296, 172.0] - rotation: 0 - state: disabled -- name: pdu_pdu_to_tagged_stream_0_0 - id: pdu_pdu_to_tagged_stream - parameters: - affinity: '' - alias: '' - comment: '' - maxoutbuf: '0' - minoutbuf: '0' - tag: packet_len - type: byte - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [304, 300.0] - rotation: 0 - state: enabled -- name: qtgui_time_sink_x_0_0 - id: qtgui_time_sink_x - parameters: - affinity: '' - alias: '' - alpha1: '1.0' - alpha10: '1.0' - alpha2: '1.0' - alpha3: '1.0' - alpha4: '1.0' - alpha5: '1.0' - alpha6: '1.0' - alpha7: '1.0' - alpha8: '1.0' - alpha9: '1.0' - autoscale: 'False' - axislabels: 'True' - color1: blue - color10: dark blue - color2: red - color3: green - color4: black - color5: cyan - color6: magenta - color7: yellow - color8: dark red - color9: dark green - comment: '' - ctrlpanel: 'True' - entags: 'True' - grid: 'False' - gui_hint: '' - label1: Quadrature - label10: Signal 10 - label2: Amplitude - label3: Signal 3 - label4: Signal 4 - label5: Signal 5 - label6: Signal 6 - label7: Signal 7 - label8: Signal 8 - label9: Signal 9 - legend: 'True' - marker1: '-1' - marker10: '-1' - marker2: '-1' - marker3: '-1' - marker4: '-1' - marker5: '-1' - marker6: '-1' - marker7: '-1' - marker8: '-1' - marker9: '-1' - name: '"Quadrature"' - nconnections: '2' - size: '1024' - srate: samp_rate - stemplot: 'False' - style1: '1' - style10: '1' - style2: '1' - style3: '1' - style4: '1' - style5: '1' - style6: '1' - style7: '1' - style8: '1' - style9: '1' - tr_chan: '1' - tr_delay: '0' - tr_level: '0.01' - tr_mode: qtgui.TRIG_MODE_NORM - tr_slope: qtgui.TRIG_SLOPE_POS - tr_tag: '""' - type: float - update_time: '0.10' - width1: '1' - width10: '1' - width2: '1' - width3: '1' - width4: '1' - width5: '1' - width6: '1' - width7: '1' - width8: '1' - width9: '1' - ylabel: Amplitude - ymax: '1' - ymin: '-1' - yunit: '""' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [680, 900.0] - rotation: 0 - state: disabled -- name: qtgui_time_sink_x_0_0_0 - id: qtgui_time_sink_x - parameters: - affinity: '' - alias: '' - alpha1: '1.0' - alpha10: '1.0' - alpha2: '1.0' - alpha3: '1.0' - alpha4: '1.0' - alpha5: '1.0' - alpha6: '1.0' - alpha7: '1.0' - alpha8: '1.0' - alpha9: '1.0' - autoscale: 'False' - axislabels: 'True' - color1: blue - color10: dark blue - color2: red - color3: green - color4: black - color5: cyan - color6: magenta - color7: yellow - color8: dark red - color9: dark green - comment: '' - ctrlpanel: 'True' - entags: 'True' - grid: 'False' - gui_hint: '' - label1: Quadrature - label10: Signal 10 - label2: Amplitude - label3: Signal 3 - label4: Signal 4 - label5: Signal 5 - label6: Signal 6 - label7: Signal 7 - label8: Signal 8 - label9: Signal 9 - legend: 'True' - marker1: '-1' - marker10: '-1' - marker2: '-1' - marker3: '-1' - marker4: '-1' - marker5: '-1' - marker6: '-1' - marker7: '-1' - marker8: '-1' - marker9: '-1' - name: '"Quadrature"' - nconnections: '1' - size: '1024' - srate: samp_rate - stemplot: 'False' - style1: '1' - style10: '1' - style2: '1' - style3: '1' - style4: '1' - style5: '1' - style6: '1' - style7: '1' - style8: '1' - style9: '1' - tr_chan: '0' - tr_delay: '0' - tr_level: '0.01' - tr_mode: qtgui.TRIG_MODE_NORM - tr_slope: qtgui.TRIG_SLOPE_POS - tr_tag: '""' - type: float - update_time: '0.10' - width1: '1' - width10: '1' - width2: '1' - width3: '1' - width4: '1' - width5: '1' - width6: '1' - width7: '1' - width8: '1' - width9: '1' - ylabel: Amplitude - ymax: '1' - ymin: '-1' - yunit: '""' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [232, 628.0] - rotation: 0 - state: disabled -- name: virtual_sink_0 - id: virtual_sink - parameters: - alias: '' - comment: '' - stream_id: bits - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [1024, 172.0] - rotation: 0 - state: disabled -- name: virtual_sink_0_0 - id: virtual_sink - parameters: - alias: '' - comment: '' - stream_id: bits - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [712, 300.0] - rotation: 0 - state: enabled -- name: virtual_source_0 - id: virtual_source - parameters: - alias: '' - comment: '' - stream_id: bits - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [56, 468.0] - rotation: 0 - state: true - -connections: -- [analog_frequency_modulator_fc_0_0, '0', blocks_multiply_xx_0, '0'] -- [analog_quadrature_demod_cf_0_0, '0', blocks_float_to_complex_0, '0'] -- [analog_quadrature_demod_cf_0_0, '0', qtgui_time_sink_x_0_0, '0'] -- [analog_sig_source_x_0_0, '0', blocks_multiply_xx_0_0, '1'] -- [blocks_add_const_vxx_0, '0', virtual_sink_0, '0'] -- [blocks_char_to_float_0, '0', blocks_add_const_vxx_0, '0'] -- [blocks_char_to_float_0_0, '0', virtual_sink_0_0, '0'] -- [blocks_complex_to_mag_0, '0', blocks_float_to_complex_0, '1'] -- [blocks_complex_to_mag_0, '0', qtgui_time_sink_x_0_0, '1'] -- [blocks_float_to_complex_0, '0', blocks_file_sink_0_0, '0'] -- [blocks_float_to_complex_0, '0', blocks_null_sink_0, '0'] -- [blocks_float_to_complex_1, '0', blocks_multiply_xx_0, '1'] -- [blocks_multiply_xx_0, '0', low_pass_filter_0, '0'] -- [blocks_multiply_xx_0_0, '0', fosphor_qt_sink_c_0_0_0, '0'] -- [blocks_multiply_xx_0_0, '0', osmosdr_sink_0_0, '0'] -- [blocks_null_source_0, '0', blocks_float_to_complex_1, '1'] -- [blocks_repeat_0_0, '0', analog_frequency_modulator_fc_0_0, '0'] -- [blocks_repeat_0_0, '0', blocks_float_to_complex_1, '0'] -- [blocks_repeat_0_0, '0', qtgui_time_sink_x_0_0_0, '0'] -- [blocks_unpack_k_bits_bb_0, '0', blocks_char_to_float_0, '0'] -- [low_pass_filter_0, '0', blocks_multiply_xx_0_0, '0'] -- [network_socket_pdu_0, pdus, pdu_pdu_to_tagged_stream_0, pdus] -- [network_socket_pdu_0_0, pdus, pdu_pdu_to_tagged_stream_0_0, pdus] -- [osmosdr_source_0, '0', analog_quadrature_demod_cf_0_0, '0'] -- [osmosdr_source_0, '0', blocks_complex_to_mag_0, '0'] -- [osmosdr_source_0, '0', fosphor_qt_sink_c_0_0, '0'] -- [pdu_pdu_to_tagged_stream_0, '0', blocks_unpack_k_bits_bb_0, '0'] -- [pdu_pdu_to_tagged_stream_0_0, '0', blocks_char_to_float_0_0, '0'] -- [virtual_source_0, '0', blocks_repeat_0_0, '0'] - -metadata: - file_format: 1 - grc_version: 3.10.2.0 diff --git a/components/spi-cc1200/sdr/send.py b/components/spi-cc1200/sdr/send.py deleted file mode 100644 index 2698f20..0000000 --- a/components/spi-cc1200/sdr/send.py +++ /dev/null @@ -1,21 +0,0 @@ -import os -import socket -import struct -import sys -from binascii import * - -import crcmod - -s = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) - -pdu = unhexlify(sys.argv[1]) -pdu = os.urandom(6 * 3) -pdu = struct.pack("B", len(pdu)) + pdu -pdu = unhexlify("aaaaaa930b51de") + pdu + struct.pack(">H", crcmod.mkCrcFun(0x18005, rev=False, initCrc=0xFFFF, - xorOut=0x0000)(pdu)) - -s.sendto(pdu, ("127.0.0.1", 52001)) - -pdu = b"".join(map(lambda x: b"\xff" if x == "0" else b"\x01", bin(int(hexlify(pdu), 16))[2:])) -pdu = b"\x00" * 128 + pdu + b"\x00" * 128 -s.sendto(pdu, ("127.0.0.1", 1234)) diff --git a/components/spi-cc1200/sdr/troopers.py b/components/spi-cc1200/sdr/troopers.py deleted file mode 100644 index e0a1770..0000000 --- a/components/spi-cc1200/sdr/troopers.py +++ /dev/null @@ -1,51 +0,0 @@ -import hashlib -import os -import socket -import struct -import sys -from binascii import hexlify, unhexlify - -import crcmod - -SECRET = b"iubeex9aJeinahphae8QuaV1eithooya" -HASH_CHAIN_LEN = 16384 - -state = SECRET -chain = [] -for i in range(HASH_CHAIN_LEN): - m = hashlib.sha256() - m.update(state) - state = m.digest() - chain += [state] -chain.reverse() - -print("#define CC1200_TROOPERS_CHAIN_TAIL \"%s\"" % "".join(map(lambda b: "\\x%02x" % b, chain[0]))) - -if len(sys.argv) != 3: - print("usage: %s cmd pyld" % sys.argv[0]) - sys.exit(1) - -if os.path.exists("state_msgid.int"): - with open("state_msgid.int", "r") as f: - msgid = int(f.read()) - msgid += 1 -else: - msgid = 0 - -print(b"\n".join(map(hexlify, chain[:msgid])).decode("utf-8")) -troopers_msg = struct.pack("H", crcmod.mkCrcFun(0x18005, rev=False, initCrc=0xFFFF, - xorOut=0x0000)(pdu)) - -with open("state_msgid.int", "w") as f: - f.write("%d" % msgid) - -s = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) -s.sendto(pdu, ("127.0.0.1", 52001)) - -pdu = b"".join(map(lambda x: b"\xff" if x == "0" else b"\x01", bin(int(hexlify(pdu), 16))[2:])) -pdu = b"\x00" * 128 + pdu + b"\x00" * 128 -s.sendto(pdu, ("127.0.0.1", 1234)) diff --git a/components/spi-cc1200/sdr/troopers_contdown.py b/components/spi-cc1200/sdr/troopers_contdown.py deleted file mode 100644 index 56e1c0c..0000000 --- a/components/spi-cc1200/sdr/troopers_contdown.py +++ /dev/null @@ -1,64 +0,0 @@ -import hashlib -import os -import socket -import struct -import sys -import time -from binascii import hexlify, unhexlify - -import crcmod - -SECRET = b"iubeex9aJeinahphae8QuaV1eithooya" -HASH_CHAIN_LEN = 16384 - -state = SECRET -chain = [] -for i in range(HASH_CHAIN_LEN): - m = hashlib.sha256() - m.update(state) - state = m.digest() - chain += [state] -chain.reverse() - -print("#define CC1200_TROOPERS_CHAIN_TAIL \"%s\"" % "".join(map(lambda b: "\\x%02x" % b, chain[0]))) - -if len(sys.argv) != 2: - print("usage: %s time" % sys.argv[0]) - sys.exit(1) - -if os.path.exists("state_msgid.int"): - with open("state_msgid.int", "r") as f: - msgid = int(f.read()) -else: - msgid = 0 - -time_left = int(sys.argv[1]) -cmd = 1 -msgid += 1 -while time_left > 30: - start = time.time() - troopers_msg = struct.pack("H", crcmod.mkCrcFun(0x18005, rev=False, initCrc=0xFFFF, - xorOut=0x0000)(pdu)) - - # with open("state_msgid.int", "w") as f: - # f.write("%d" % msgid) - - s = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) - s.sendto(pdu, ("127.0.0.1", 52001)) - - pdu = b"".join(map(lambda x: b"\xff" if x == "0" else b"\x01", bin(int(hexlify(pdu), 16))[2:])) - pdu = b"\x00" * 128 + pdu + b"\x00" * 128 - s.sendto(pdu, ("127.0.0.1", 1234)) - - time.sleep(1 - (time.time() - start)) - time_left -= 1 - -while time_left > 0: - start = time.time() - time.sleep(1 - (time.time() - start)) - time_left -= 1 - print("time_left %d" % time_left) diff --git a/components/spi-cc1200/troopers.c b/components/spi-cc1200/troopers.c deleted file mode 100644 index da0e0a7..0000000 --- a/components/spi-cc1200/troopers.c +++ /dev/null @@ -1,472 +0,0 @@ -#include -#include - - -#include "include/cc1200_troopers.h" -#include "include/driver_cc1200.h" - -#include "nvs.h" -#include "nvs_flash.h" - -static const char *TAG = "driver_cc1200"; - -static const char *handle = "cc1200_troopers"; -static const char *key = "state"; - -xSemaphoreHandle driver_cc1200_troopers_task_mux = NULL; -TaskHandle_t driver_cc1200_troopers_task_handle = NULL; - -uint8_t last_effect = 0; -uint32_t remaining_ticks = 0; -extern bool driver_cc1200_troopers_animation_running = false; - -#define TICKS_PER_MS (1. / portTICK_PERIOD_MS) -#define TICKS_PER_S (1000 * TICKS_PER_MS) -#define LED_OFF "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" -#define LED_ORANGE "\xea\xa3\x07\xea\xa3\x07\xea\xa3\x07\xea\xa3\x07\xea\xa3\x07\xea\xa3\x07" - -void driver_cc1200_troopers_task(void *arg) { - while (1) { - if (xSemaphoreTake(driver_cc1200_troopers_task_mux, portMAX_DELAY) != pdTRUE) continue; // TIMEOUT - ESP_LOGI(TAG, "Countdown: start"); - uint32_t start; - uint32_t diff; - int32_t delay; - while (1) { - start = xTaskGetTickCount(); - if (remaining_ticks < 100 * TICKS_PER_MS) { - if (last_effect > 0) { - ESP_LOGI(TAG, "Countdown: 100ms"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 0; - } - } else if (remaining_ticks < 200 * TICKS_PER_MS) { - if (last_effect > 1) { - ESP_LOGI(TAG, "Countdown: 200ms"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif - last_effect = 1; - } - } else if (remaining_ticks < 300 * TICKS_PER_MS) { - if (last_effect > 2) { - ESP_LOGI(TAG, "Countdown: 300ms"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 2; - } - } else if (remaining_ticks < 400 * TICKS_PER_MS) { - if (last_effect > 3) { - ESP_LOGI(TAG, "Countdown: 400ms"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif - last_effect = 3; - } - } else if (remaining_ticks < 500 * TICKS_PER_MS) { - if (last_effect > 4) { - ESP_LOGI(TAG, "Countdown: 500ms"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 4; - } - } else if (remaining_ticks < 600 * TICKS_PER_MS) { - if (last_effect > 5) { - ESP_LOGI(TAG, "Countdown: 600ms"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif - last_effect = 5; - } - } else if (remaining_ticks < 700 * TICKS_PER_MS) { - if (last_effect > 6) { - ESP_LOGI(TAG, "Countdown: 700ms"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 6; - } - } else if (remaining_ticks < 800 * TICKS_PER_MS) { - if (last_effect > 7) { - ESP_LOGI(TAG, "Countdown: 800ms"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif - last_effect = 7; - } - } else if (remaining_ticks < 900 * TICKS_PER_MS) { - if (last_effect > 8) { - ESP_LOGI(TAG, "Countdown: 900ms"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 8; - } - } else if (remaining_ticks < 1 * TICKS_PER_S) { - if (last_effect > 9) { - ESP_LOGI(TAG, "Countdown: 1s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play_async(16); -#endif - last_effect = 9; - } - } else if (remaining_ticks < 2 * TICKS_PER_S) { - if (last_effect > 10) { - ESP_LOGI(TAG, "Countdown: 2s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(14); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 10; - } - } else if (remaining_ticks < 3 * TICKS_PER_S) { - if (last_effect > 11) { - ESP_LOGI(TAG, "Countdown: 3s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(14); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 11; - } - } else if (remaining_ticks < 4 * TICKS_PER_S) { - if (last_effect > 12) { - ESP_LOGI(TAG, "Countdown: 4s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(14); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 12; - } - } else if (remaining_ticks < 5 * TICKS_PER_S) { - if (last_effect > 13) { - ESP_LOGI(TAG, "Countdown: 5s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(14); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 13; - } - } else if (remaining_ticks < 6 * TICKS_PER_S) { - if (last_effect > 14) { - ESP_LOGI(TAG, "Countdown: 6s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(72); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 14; - } - } else if (remaining_ticks < 7 * TICKS_PER_S) { - if (last_effect > 15) { - ESP_LOGI(TAG, "Countdown: 7s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(72); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 15; - } - } else if (remaining_ticks < 8 * TICKS_PER_S) { - if (last_effect > 16) { - ESP_LOGI(TAG, "Countdown: 8s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(72); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 16; - } - } else if (remaining_ticks < 9 * TICKS_PER_S) { - if (last_effect > 17) { - ESP_LOGI(TAG, "Countdown: 9s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(72); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 17; - } - } else if (remaining_ticks < 10 * TICKS_PER_S) { - if (last_effect > 18) { - ESP_LOGI(TAG, "Countdown: 10s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(72); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 18; - } - } else if (remaining_ticks < 15 * TICKS_PER_S) { - if (last_effect > 19) { - ESP_LOGI(TAG, "Countdown: 15s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(16); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 19; - } - } else if (remaining_ticks < 30 * TICKS_PER_S) { - if (last_effect > 20) { - ESP_LOGI(TAG, "Countdown: 30s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(71); - driver_drv2605l_play(71); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 20; - } - } else if (remaining_ticks < 60 * TICKS_PER_S) { - if (last_effect > 21) { - ESP_LOGI(TAG, "Countdown: 60s"); -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_ORANGE, 18); -#endif -#ifdef CONFIG_DRIVER_DRV2605L_ENABLE - driver_drv2605l_play(71); -#endif -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - last_effect = 21; - } - } - diff = xTaskGetTickCount() - start; - if (remaining_ticks < diff) break; - remaining_ticks -= diff; - delay = (100 * TICKS_PER_MS) - diff; - if (delay > 0) { - vTaskDelay(delay); - if (remaining_ticks < delay) break; - remaining_ticks -= delay; - } - } -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) LED_OFF, 18); -#endif - ESP_LOGI(TAG, "Countdown finished"); - driver_cc1200_troopers_animation_running = false; - } -} - -esp_err_t cc1200_troopers_init() { - driver_cc1200_troopers_task_mux = xSemaphoreCreateMutex(); - if (driver_cc1200_troopers_task_mux == NULL) return ESP_ERR_NO_MEM; - xTaskCreate(&driver_cc1200_troopers_task, "CC1200 Troopers interrupt task", 4096, NULL, 10, &driver_cc1200_troopers_task_handle); - return ESP_OK; -} - -esp_err_t get_last_state(cc1200_troopers_state_t *value) { - nvs_handle my_handle; - size_t bufflen = sizeof(cc1200_troopers_state_t); - - esp_err_t res = nvs_open(handle, NVS_READWRITE, &my_handle); - if (res != ESP_OK) { - ESP_LOGE(TAG, "NVS handle not found!"); - return ESP_FAIL; - } - - if (ESP_ERR_NVS_NOT_FOUND == nvs_get_blob(my_handle, key, value, &bufflen)) { - value->msgid = 0; - memcpy(value->hash, CC1200_TROOPERS_CHAIN_TAIL, CC1200_TROOPERS_HASH_SIZE); - } else if (bufflen != sizeof(cc1200_troopers_state_t)) { - ESP_LOGE(TAG, "NVS expected to read %d bytes, got %d bytes", sizeof(cc1200_troopers_state_t), bufflen); - return ESP_FAIL; - } - nvs_close(my_handle); - - return ESP_OK; -} - -esp_err_t set_last_state(const cc1200_troopers_state_t *value) { - nvs_handle my_handle; - esp_err_t res = nvs_open(handle, NVS_READWRITE, &my_handle); - if (res != ESP_OK) { - ESP_LOGE(TAG, "NVS handle not found!"); - return 1; - } - - esp_err_t esp_err = nvs_set_blob(my_handle, key, value, sizeof(cc1200_troopers_state_t)); - if (ESP_OK == esp_err) { - nvs_commit(my_handle); - nvs_close(my_handle); - return ESP_OK; - } else if (ESP_ERR_NVS_NOT_ENOUGH_SPACE == esp_err || ESP_ERR_NVS_PAGE_FULL == esp_err || ESP_ERR_NVS_NO_FREE_PAGES == esp_err) { - ESP_LOGE(TAG, "No space available."); - } else if (ESP_ERR_NVS_INVALID_NAME == esp_err || ESP_ERR_NVS_KEY_TOO_LONG == esp_err) { - ESP_LOGE(TAG, "Key invalid or too long"); - } - nvs_close(my_handle); - return 2; -} - -bool cc1200_troopers_replay_protection(cc1200_troopers_message_t *msg) { - cc1200_troopers_state_t state; - esp_err_t res; - res = get_last_state(&state); - if (res != ESP_OK) { - ESP_LOGW(TAG, "get state error"); - return false; - } - - if (msg->msgid <= state.msgid) { - ESP_LOGW(TAG, "Replay %d %d", msg->msgid, state.msgid); - return false; - } - - if (msg->msgid - state.msgid > CC1200_TROOPERS_MAX_BEHIND) { - ESP_LOGE(TAG, "Too faar behind %d %d", msg->msgid, state.msgid); - return false; - } - - uint8_t node[CC1200_TROOPERS_HASH_SIZE]; - memcpy(node, msg->hash, CC1200_TROOPERS_HASH_SIZE); - ESP_LOGI(TAG, "msg=%d state=%d", msg->msgid, state.msgid); - ESP_LOGI(TAG, "--GOT--------------------------------"); - ESP_LOG_BUFFER_HEX_LEVEL(TAG, node, 32, ESP_LOG_INFO); - while (state.msgid != msg->msgid) { - mbedtls_sha256(node, CC1200_TROOPERS_HASH_SIZE, node, 0); - state.msgid++; - ESP_LOGI(TAG, "-------------------------------------"); - ESP_LOG_BUFFER_HEX_LEVEL(TAG, node, 32, ESP_LOG_INFO); - } - - ESP_LOGI(TAG, "--EXPECTED---------------------------"); - ESP_LOG_BUFFER_HEX_LEVEL(TAG, state.hash, 32, ESP_LOG_INFO); - if (memcmp(state.hash, node, CC1200_TROOPERS_HASH_SIZE) == 0) { - memcpy(state.hash, msg->hash, CC1200_TROOPERS_HASH_SIZE); - res = set_last_state(&state); - if (res != ESP_OK) { - return false; - } - return true; - } else - ESP_LOGW(TAG, "Hash mismatch"); - - return false; -} - -void cc1200_debug_start_countdown() { - remaining_ticks = 65 * TICKS_PER_S; - last_effect = -1; - ESP_LOGI(TAG, "Start countdown, %d", remaining_ticks); - ESP_LOGI(TAG, "Start countdown, %d", portTICK_PERIOD_MS); - ESP_LOGI(TAG, "Start countdown, %f", TICKS_PER_MS); - ESP_LOGI(TAG, "Start countdown, %f", TICKS_PER_S); - xSemaphoreGive(driver_cc1200_troopers_task_mux); -} - -bool cc1200_troopers_cb(cc1200_message *pkg) { - cc1200_troopers_message_t *msg = (cc1200_troopers_message_t *) pkg->data; - if (msg->magic != CC1200_TROOPERS_MAGIC) { - return false; - } - - if (pkg->len != sizeof(cc1200_troopers_message_t)) { - ESP_LOGW(TAG, "Received invalid packet: len %d expected %d", pkg->len, sizeof(cc1200_troopers_message_t)); - return false; - } - - if (!cc1200_troopers_replay_protection(msg)) { - ESP_LOGW(TAG, "Received invalid packet: replay"); - return false; - } - - cc1200_troopers_state_t value; - - switch (msg->type) { - case CC1200_TROOPERS_MSGTYPE_COUNTDOWN: - remaining_ticks = msg->payload * TICKS_PER_S; - last_effect = -1; - if (!driver_cc1200_troopers_animation_running) { - ESP_LOGI(TAG, "Start countdown"); - driver_cc1200_troopers_animation_running = true; - xSemaphoreGive(driver_cc1200_troopers_task_mux); - } else - ESP_LOGI(TAG, "Setting time"); - break; - case CC1200_TROOPERS_MSGTYPE_TALK: -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) "\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00", 18); // Green -#endif - break; - case CC1200_TROOPERS_MSGTYPE_BREAK: -#ifdef CONFIG_DRIVER_NEOPIXEL_ENABLE - driver_neopixel_send_data((uint8_t *) "\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff", 18); // Blue -#endif - break; - case CC1200_TROOPERS_MSGTYPE_RESET: - // actually quite dangerous as we do not sign the command type - - // value.msgid = 0; - // memcpy(value.hash, CC1200_TROOPERS_CHAIN_TAIL, CC1200_TROOPERS_HASH_SIZE); - // set_last_state(&value); - // ESP_LOGI(TAG, "RESET"); - // break; - case CC1200_TROOPERS_MSGTYPE_COUNTDOWN_SET_TIME: // Duplicate as CC1200_TROOPERS_MSGTYPE_COUNTDOWN: does now similar things - remaining_ticks = msg->payload * portTICK_PERIOD_MS; - last_effect = -1; - ESP_LOGI(TAG, "Set remaining ms to: %d", remaining_ticks / portTICK_PERIOD_MS); - break; - default: - ESP_LOGW(TAG, "Received invalid packet: msg type"); - } - - return true; -} diff --git a/components/troopers23-bsp b/components/troopers23-bsp deleted file mode 160000 index a1d8b3a..0000000 --- a/components/troopers23-bsp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a1d8b3a57cfbc6389eee4b2b9c8acffe8a5767d4 diff --git a/components/troopers24-bsp b/components/troopers24-bsp new file mode 160000 index 0000000..9822bf9 --- /dev/null +++ b/components/troopers24-bsp @@ -0,0 +1 @@ +Subproject commit 9822bf972a0097ebb897f9b9b7f49b3627d69af2 diff --git a/components/troopers23-efuse b/components/troopers24-efuse similarity index 100% rename from components/troopers23-efuse rename to components/troopers24-efuse diff --git a/main/factory_test.c b/main/factory_test.c index 1bdc0f8..a0e161f 100644 --- a/main/factory_test.c +++ b/main/factory_test.c @@ -20,18 +20,6 @@ static const char* TAG = "factory"; -bool test_cc1200_init(uint32_t* rc) { - CC1200 cc1200 = {0}; - - cc1200.spi_bus = SPI_BUS; - cc1200.pin_cs = GPIO_SPI_CS_RADIO; - cc1200.pin_intr = GPIO_INT_RADIO; - cc1200.spi_speed = 20000000; // 20MHz - - esp_err_t res = cc1200_init(&cc1200); - *rc = (uint32_t) res; - return (res == ESP_OK); -} bool wait_for_key_pressed(Keyboard* keyboard, Key key) { keyboard_input_message_t buttonMessage = {0}; @@ -72,28 +60,6 @@ bool test_keyboard_init(uint32_t* rc) { *rc = (uint32_t) 2; return false; } - ESP_LOGI(TAG, "Press SHIFT..."); - pax_simple_rect(pax_buffer, 0xFFFFFFFF, 0, pax_buffer->height - 36, pax_buffer->width, 36); - pax_draw_text(pax_buffer, 0xFF0000FF, font, 36, 0, pax_buffer->height - 36, "Press SHIFT"); - display_flush(); - if (!wait_for_key_pressed(keyboard, KEY_SHIFT)) { - ESP_LOGE(TAG, "Timeout reached"); - pax_simple_rect(pax_buffer, 0xFFFFFFFF, 0, pax_buffer->height - 36, pax_buffer->width, 36); - display_flush(); - *rc = (uint32_t) 3; - return false; - } - ESP_LOGI(TAG, "Press Q..."); - pax_simple_rect(pax_buffer, 0xFFFFFFFF, 0, pax_buffer->height - 36, pax_buffer->width, 36); - pax_draw_text(pax_buffer, 0xFF0000FF, font, 36, 0, pax_buffer->height - 36, "Press Q"); - display_flush(); - if (!wait_for_key_pressed(keyboard, KEY_Q)) { - ESP_LOGE(TAG, "Timeout reached"); - pax_simple_rect(pax_buffer, 0xFFFFFFFF, 0, pax_buffer->height - 36, pax_buffer->width, 36); - display_flush(); - *rc = (uint32_t) 4; - return false; - } pax_simple_rect(pax_buffer, 0xFFFFFFFF, 0, pax_buffer->height - 36, pax_buffer->width, 36); display_flush(); @@ -186,7 +152,6 @@ bool run_basic_tests() { /* Run mandatory tests */ RUN_TEST_MANDATORY("KEYBOARD", test_keyboard_init); - RUN_TEST_MANDATORY("CC1200", test_cc1200_init); /* Run tests */ RUN_TEST("STUCK BUTTONS", test_stuck_buttons); diff --git a/main/nametag.c b/main/nametag.c index 421b1da..da75f38 100644 --- a/main/nametag.c +++ b/main/nametag.c @@ -53,7 +53,7 @@ void edit_nickname(xQueueHandle button_queue) { clear_keyboard_queue(); bool accepted = - keyboard(button_queue, 30, 30, pax_buffer->width - 60, pax_buffer->height - 60, "Nickname", "🅰 accept 🅱 cancel", nickname, sizeof(nickname) - 1); + keyboard(button_queue, 30, 30, pax_buffer->width - 60, pax_buffer->height - 60, "Nickname", "🆂 cancel 🅳 D 🅴 Select 🅱 delete", nickname, sizeof(nickname) - 1); if (accepted) { nvs_set_str(handle, "nickname", nickname); diff --git a/package.sh b/package.sh new file mode 100755 index 0000000..9c8d3f4 --- /dev/null +++ b/package.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +rm -rf ../dist/ +mkdir ../dist/ +cp build/bootloader/bootloader.bin ../dist/ +cp build/partition_table/partition-table.bin ../dist/ +cp build/ota_data_initial.bin ../dist/ +cp build/phy_init_data.bin ../dist/ +cp build/TROOPERS23.bin ../dist/ + +(cd components/appfs/tools/; ./generate.sh) + +cp components/appfs/tools/appfs.bin ../dist/ + +echo "#!/bin/bash" > ../dist/flash.sh +echo "" >> ../dist/flash.sh +echo 'DEVICE=$1' >> ../dist/flash.sh +echo "esptool.py erase_flash" >> ../dist/flash.sh +echo 'esptool.py -p $DEVICE -b 460800 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x1000 bootloader.bin 0x8000 partition-table.bin 0xd000 ota_data_initial.bin 0xf000 phy_init_data.bin 0x10000 TROOPERS23.bin' >> ../dist/flash.sh +echo 'esptool.py --port $DEVICE --baud 960000 write_flash 0x330000 appfs.bin' >> ../dist/flash.sh +chmod +x ../dist/flash.sh + +rm -f ../dist.zip +zip -r ../dist.zip ../dist/ diff --git a/sdkconfig b/sdkconfig index 59c48a2..040b98d 100644 --- a/sdkconfig +++ b/sdkconfig @@ -50,8 +50,16 @@ CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set CONFIG_BOOTLOADER_LOG_LEVEL=1 + +# +# Serial Flash Configurations +# # CONFIG_BOOTLOADER_SPI_CUSTOM_WP_PIN is not set CONFIG_BOOTLOADER_SPI_WP_PIN=7 +# CONFIG_BOOTLOADER_FLASH_DC_AWARE is not set +CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y +# end of Serial Flash Configurations + CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y # CONFIG_BOOTLOADER_FACTORY_RESET is not set # CONFIG_BOOTLOADER_APP_TEST is not set @@ -65,7 +73,6 @@ CONFIG_BOOTLOADER_WDT_TIME_MS=9000 # CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set -CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y # end of Bootloader config # @@ -224,6 +231,7 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set # CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set # CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set +# CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM is not set # end of TWAI configuration # @@ -281,9 +289,16 @@ CONFIG_ESP_TLS_USING_MBEDTLS=y CONFIG_ESP32_ECO3_CACHE_LOCK_FIX=y # CONFIG_ESP32_REV_MIN_0 is not set CONFIG_ESP32_REV_MIN_1=y +# CONFIG_ESP32_REV_MIN_1_1 is not set # CONFIG_ESP32_REV_MIN_2 is not set # CONFIG_ESP32_REV_MIN_3 is not set +# CONFIG_ESP32_REV_MIN_3_1 is not set CONFIG_ESP32_REV_MIN=1 +CONFIG_ESP32_REV_MIN_FULL=100 +CONFIG_ESP_REV_MIN_FULL=100 +CONFIG_ESP32_REV_MAX_FULL_STR_OPT=y +CONFIG_ESP32_REV_MAX_FULL=399 +CONFIG_ESP_REV_MAX_FULL=399 CONFIG_ESP32_DPORT_WORKAROUND=y # CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set # CONFIG_ESP32_DEFAULT_CPU_FREQ_160 is not set @@ -487,6 +502,7 @@ CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y # CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 +# CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR is not set # end of MAC Config # @@ -496,6 +512,7 @@ CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y # CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set # CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND is not set # CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set +CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y # end of Sleep Config # @@ -516,6 +533,10 @@ CONFIG_ESP_IPC_ISR_ENABLE=y # LCD and Touch Panel # +# +# LCD Touch Drivers are maintained in the IDF Component Registry +# + # # LCD Peripheral Configuration # @@ -542,6 +563,10 @@ CONFIG_ESP_PHY_DEFAULT_INIT_IF_INVALID=y CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 CONFIG_ESP_PHY_MAX_TX_POWER=20 CONFIG_ESP_PHY_REDUCE_TX_POWER=y +CONFIG_ESP_PHY_RF_CAL_PARTIAL=y +# CONFIG_ESP_PHY_RF_CAL_NONE is not set +# CONFIG_ESP_PHY_RF_CAL_FULL is not set +CONFIG_ESP_PHY_CALIBRATION_MODE=0 # end of PHY # @@ -623,6 +648,10 @@ CONFIG_ESP32_WIFI_STATIC_TX_BUFFER=y CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=0 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=16 CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=32 +CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y +# CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set +CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0 +CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF=5 # CONFIG_ESP32_WIFI_CSI_ENABLED is not set CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y CONFIG_ESP32_WIFI_TX_BA_WIN=6 @@ -823,7 +852,9 @@ CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y # CONFIG_LWIP_LOCAL_HOSTNAME="badge" # CONFIG_LWIP_NETIF_API is not set +CONFIG_LWIP_TCPIP_TASK_PRIO=18 # CONFIG_LWIP_TCPIP_CORE_LOCKING is not set +# CONFIG_LWIP_CHECK_THREAD_SAFETY is not set CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_L2_TO_L3_COPY is not set # CONFIG_LWIP_IRAM_OPTIMIZATION is not set @@ -835,6 +866,7 @@ CONFIG_LWIP_SO_REUSE=y CONFIG_LWIP_SO_REUSE_RXTOALL=y # CONFIG_LWIP_SO_RCVBUF is not set # CONFIG_LWIP_NETBUF_RECVINFO is not set +CONFIG_LWIP_IP_DEFAULT_TTL=64 CONFIG_LWIP_IP4_FRAG=y CONFIG_LWIP_IP6_FRAG=y # CONFIG_LWIP_IP4_REASSEMBLY is not set @@ -844,12 +876,15 @@ CONFIG_LWIP_IP6_FRAG=y # CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set CONFIG_LWIP_ESP_GRATUITOUS_ARP=y CONFIG_LWIP_GARP_TMR_INTERVAL=60 +CONFIG_LWIP_ESP_MLDV6_REPORT=y +CONFIG_LWIP_MLDV6_TMR_INTERVAL=40 CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y # CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y # CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set CONFIG_LWIP_DHCP_OPTIONS_LEN=68 +CONFIG_LWIP_DHCP_COARSE_TIMER_SECS=1 # # DHCP server @@ -884,6 +919,8 @@ CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 CONFIG_LWIP_TCP_WND_DEFAULT=5744 CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 CONFIG_LWIP_TCP_QUEUE_OOSEQ=y +CONFIG_LWIP_TCP_OOSEQ_TIMEOUT=6 +CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS=4 # CONFIG_LWIP_TCP_SACK_OUT is not set # CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set CONFIG_LWIP_TCP_OVERSIZE_MSS=y @@ -939,6 +976,13 @@ CONFIG_LWIP_SNTP_MAX_SERVERS=1 CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 # end of SNTP +# +# DNS +# +CONFIG_LWIP_DNS_MAX_SERVERS=3 +# CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT is not set +# end of DNS + CONFIG_LWIP_ESP_LWIP_ASSERT=y # @@ -1165,6 +1209,20 @@ CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # end of PThreads +# +# Main Flash configuration +# + +# +# Optional and Experimental Features (READ DOCS FIRST) +# + +# +# Features here require specific hardware (READ DOCS FIRST!) +# +# end of Optional and Experimental Features (READ DOCS FIRST) +# end of Main Flash configuration + # # SPI Flash driver # @@ -1259,6 +1317,11 @@ CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y # CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set # end of Unity unit testing library +# +# Root Hub configuration +# +# end of Root Hub configuration + # # Virtual file system #