-
Notifications
You must be signed in to change notification settings - Fork 1
Solids Test #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zizz-0
wants to merge
46
commits into
main
Choose a base branch
from
zizz/solids-test-board
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Solids Test #348
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
49c2fb6
solids project setup
zizz-0 4693d9f
solids test code builds, untested
zizz-0 94a8979
new overlay and adc channel cfg
zizz-0 e2b3276
folder renamed
zizz-0 a178bd6
broken :(
zizz-0 0904818
fixes n things
cowsed abea238
merge conflict :(
zizz-0 1c08ff9
Merge branch 'zizz/solids-test-board' of https://github.com/RIT-Launc…
zizz-0 f04f221
halfway working maybe
zizz-0 6b274fe
renamed fr this time
zizz-0 93401a2
flash dump works, adc reading not working fast enough :(
zizz-0 1ec5a0c
got left bc of merge
cowsed 4ffc9bb
erase command, writing in blocks
cowsed 56739fc
adc fine tuning/optimiaztion
cowsed 226d095
instrumenting
cowsed 170f331
DMAing it up
cowsed 0a85a5d
ematches and reading misses
cowsed b9bb43f
stashing changes - button interrupt (not done)
zizz-0 9e82edd
Merge branch 'zizz/solids-test-board' of https://github.com/RIT-Launc…
zizz-0 8618a1f
solids test probably done. buzzer unfortunately on. tx/rx button work…
zizz-0 6736b06
checkl on flash test
cowsed a43ff19
set ematch/estop shell cmds, ematch set 500ms into adc reading instea…
zizz-0 feea5ce
Merge branch 'zizz/solids-test-board' of https://github.com/RIT-Launc…
zizz-0 554c8f0
formatting
zizz-0 d82bf52
shell print n
cowsed 7d246a5
formatting, comments, button functions moved
zizz-0 2bbf7ef
sys init
zizz-0 9837e91
main commands print update
zizz-0 a48a8bc
function definitions and sys_init
zizz-0 5dcc0ee
even more formatting
zizz-0 3955b55
logging fixed
zizz-0 d2b1cf4
don't blow up solids members code (calibration name, key switch, very…
zizz-0 2c33dde
buzzer task tested
zizz-0 827931f
comments, formatting, updated continuous_beep
zizz-0 9ae27ca
print whether test is terminal or meep, terminal formatting
zizz-0 afdbe5d
comments, rx/tx gpio interrupt conf flags
zizz-0 c65f31d
set buzzer back to buzzer instead of led :(
zizz-0 be6d159
swap tx/rx and button/key_switch
zizz-0 f71d876
clarifying comments
zizz-0 038a463
sample name
zizz-0 2ea3dde
clarified comments, fixed values (spi max freq, added const calib nam…
zizz-0 ca4a05d
clarified more comments, fix print statements, protect against concur…
zizz-0 40e4dd6
void*, void*, void* on tasks to avoid warnings, tasks exposed in head…
zizz-0 17b0b7e
while(true) instead of while(1), removed button and key switch intern…
zizz-0 fe85e14
fwd declares
zizz-0 1613455
key switch active low
cowsed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule quaternions
added at
a5ef2e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
| project(grim_reefer LANGUAGES C) | ||
|
|
||
| FILE(GLOB sources src/*.c) | ||
| target_sources(app PRIVATE ${sources}) | ||
| target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| source "Kconfig.zephyr" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /delete-node/ &adc; | ||
|
|
||
| / { | ||
| zephyr,user { | ||
| io-channels = <&adc 0>; | ||
| }; | ||
|
|
||
| aliases { | ||
| adc0 = &adc; | ||
| buzzer = &buzzer; | ||
| }; | ||
|
|
||
| leds: leds { | ||
| button: button{ // TX | ||
| gpios = <&gpioa 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>; | ||
| label = "Button"; | ||
| }; | ||
| key_switch: key_switch{ // RX | ||
| gpios = <&gpioa 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; | ||
| label = "Key Switch"; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| &uart4 { | ||
| status = "disabled"; | ||
| }; | ||
|
|
||
| &spi2 { | ||
| status = "okay"; | ||
| adc: mcp3561@0 { // new and cool driver | ||
| #io-channel-cells = <1>; | ||
| #address-cells = <1>; | ||
| #size-cells = <0>; | ||
| compatible = "microchip,mcp356xr"; | ||
| status = "okay"; | ||
| reg = <0>; | ||
| address = <1>; | ||
| analog-clock-prescaler = <0>; | ||
| boost-current-bias = <0>; | ||
| spi-max-frequency = <DT_FREQ_M(20)>; | ||
| irq-gpios = <&gpiob 14 GPIO_ACTIVE_LOW>; | ||
| use-internal-clock; | ||
|
|
||
| channel@0 { | ||
| reg = <0>; | ||
| zephyr,gain = "ADC_GAIN_32"; | ||
| zephyr,reference = "ADC_REF_INTERNAL"; | ||
| zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>; | ||
|
|
||
| zephyr,resolution = <24>; | ||
|
|
||
| zephyr,differential; | ||
| zephyr,input-positive = <0x1>; | ||
| zephyr,input-negative = <0x0>; | ||
|
|
||
| zephyr,oversampling = <7>; | ||
| }; | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #ifndef ADC_READING_H | ||
| #define ADC_READING_H | ||
|
|
||
| #include <stdint.h> | ||
| #include <stdbool.h> | ||
|
|
||
| /** | ||
| * @brief Struct to hold one ADC sample | ||
| */ | ||
| struct adc_sample { | ||
| uint32_t timestamp; /** Timestamp the sample was recorded in µs */ | ||
| int32_t value; /** Value of the sample */ | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Initialize the ADC device and channel | ||
| * @return 0 if successful | ||
| */ | ||
| int adc_init(); | ||
|
|
||
| /** | ||
| * @brief Read one ADC sample | ||
| * @param[out] adc_val Pointer to value where sample will be written | ||
| */ | ||
| void adc_read_one(uint32_t *adc_val); | ||
|
|
||
| /** | ||
| * @brief Waits for ADC reading event to start, then reads ADC samples for 10 seconds | ||
cowsed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
| void adc_reading_task(void*, void*, void*); | ||
|
|
||
| /** | ||
| * @brief Starts test | ||
| * @param[in] terminal_test Whether test was triggered by terminal cmd or meep | ||
| * If test was triggered by terminal, ematch will NOT light | ||
| */ | ||
cowsed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| void adc_start_reading(bool terminal_test); | ||
|
|
||
| /** | ||
| * @brief Stops test | ||
| */ | ||
cowsed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| void adc_stop_recording(); | ||
|
|
||
| #endif // ADC_READING_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #ifndef BUTTON_H | ||
| #define BUTTON_H | ||
|
|
||
| #include <zephyr/drivers/gpio.h> | ||
| #include <zephyr/device.h> | ||
| #include <stdint.h> | ||
|
|
||
| /** | ||
| * @brief Configures TX and RX pins as gpio | ||
| * @return 0 if successful | ||
| */ | ||
| int button_switch_init(); | ||
|
|
||
| /** | ||
| * @brief Thread to beep continuously if key switch is closed and test is not started | ||
| */ | ||
| void buzzer_task(void*, void*, void*); | ||
|
|
||
| #endif // BUTTON_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #ifndef BUZZER_H | ||
| #define BUZZER_H | ||
|
|
||
| /** | ||
| * @brief Configure buzzer and ldo gpio pins | ||
| * @return 0 if successful | ||
| */ | ||
| int buzzer_init(); | ||
|
|
||
| /** | ||
| * @brief Start or stop buzzer | ||
| * @param[in] which Value to set buzzer | ||
| */ | ||
| void set_buzz(int which); | ||
|
|
||
| /** | ||
| * @brief Set ematch gpio pin | ||
| * @param[in] level Value to assign to pin | ||
| */ | ||
| void set_ematch(int level); | ||
|
|
||
| /** | ||
| * @brief Set ldo gpio pin | ||
| * @param[in] level Value to assign to pin | ||
| */ | ||
| void set_ldo(int level); | ||
|
|
||
| /** | ||
| * @brief Beep loudly in 1 second intervals for 10 seconds to indicate that flash is full (max tests reached) | ||
| */ | ||
| void beep_full(); | ||
|
|
||
| /** | ||
| * @brief Beep loudly 3 times to indicate test start | ||
| */ | ||
| void test_start_beep(); | ||
|
|
||
| /** | ||
| * @brief Beep loudly 2 times to indicate test end | ||
| */ | ||
| void test_end_beep(); | ||
|
|
||
| /** | ||
| * @brief Beep until test starts | ||
| */ | ||
| void continuous_beep(); | ||
|
|
||
| #endif // BUZZER_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #ifndef CONFIG_H | ||
| #define CONFIG_H | ||
|
|
||
| #define SAMPLE_RATE 1000 | ||
| #define TEST_DURATION 10000 // ms | ||
| #define MAX_TESTS 30 | ||
| #define CALIB_NAME_MAX_LEN 32 // If solids members need more than 32 characters then they need better naming standards | ||
|
|
||
| #define STORAGE_THREAD_PRIORITY 1 | ||
| #define THREAD_START_DELAY 100 | ||
| #define SYS_INIT_PRIORITY 1 | ||
|
|
||
| #endif // CONFIG_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #ifndef CONTROL_H | ||
| #define CONTROL_H | ||
|
|
||
| #include <stdbool.h> | ||
| #include <zephyr/shell/shell.h> | ||
|
|
||
| /** | ||
| * @brief Starts flash storage and ADC reading | ||
| * @param[in] calib_name Name of calibration to store in flash storage | ||
| * @param[in] terminal_test Whether test was triggered by terminal cmd or meep | ||
| */ | ||
| void control_start_test(char calib_name[], bool terminal_test); | ||
|
|
||
| /** | ||
| * @brief Stops flash storage and ADC reading | ||
| */ | ||
| void control_stop_test(); | ||
|
|
||
| /** | ||
| * @brief Reads and prints n number of ADC samples | ||
| * @param[in] shell Pointer to shell instance | ||
| * @param[in] num Number of samples to read | ||
| */ | ||
| void control_print_n(const struct shell *shell, int num); | ||
|
|
||
| /** | ||
| * @brief Dumps all ADC data from flash storage | ||
| * @param[in] shell Pointer to shell instance | ||
| */ | ||
| void control_dump_data(const struct shell *shell); | ||
|
|
||
| /** | ||
| * @brief Dumps one ADC test from flash storage | ||
| * @param[in] shell Pointer to shell instance | ||
| * @param[in] test_index The test number to dump | ||
| */ | ||
| void control_dump_one(const struct shell *shell, uint32_t test_index); | ||
|
|
||
| /** | ||
| * @brief Clear all flash blocks | ||
| * @param[in] shell Pointer to shell instance | ||
| */ | ||
| void control_erase_all(const struct shell *shell); | ||
|
|
||
| /** | ||
| * @brief Set ematch gpio high | ||
| * @param[in] shell Pointer to shell instance | ||
| */ | ||
| void control_set_ematch(const struct shell *shell); | ||
|
|
||
| /** | ||
| * @brief Set ematch gpio low | ||
| * @param[in] shell Pointer to shell instance | ||
| */ | ||
| void control_stop_ematch(const struct shell *shell); | ||
|
|
||
| /** | ||
| * @brief Get status of test | ||
| * @return Whether a test is running or not | ||
| */ | ||
| bool control_get_test_status(); | ||
|
|
||
| #endif // CONTROL_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #ifndef FLASH_STORAGE_H | ||
| #define FLASH_STORAGE_H | ||
|
|
||
| #include <zephyr/shell/shell.h> | ||
| #include <stdint.h> | ||
|
|
||
| /** | ||
| * @brief Thread to save test data to flash storage | ||
| */ | ||
| void flash_storage_thread_entry(void*, void*, void*); | ||
|
|
||
| /** | ||
| * @brief Begin flash storage event | ||
| * @param[in] calib_name Name of calibration to store. Defaults to "Test [#]" if empty or default string passed in | ||
| * @param[in] terminal_test Whether test was triggered by terminal cmd or meep | ||
| * @return 0 if successful | ||
| */ | ||
| int start_flash_storage(char calib_name[], bool terminal_test); | ||
|
|
||
| /** | ||
| * @brief End flash storage event | ||
| */ | ||
| void stop_flash_storage(); | ||
|
|
||
| /** | ||
| * @brief Dumps one ADC test from flash storage | ||
| * @param[in] shell Pointer to shell instance | ||
| * @param[in] test_index The test number to dump | ||
| * @return 0 if successful | ||
| */ | ||
| int flash_dump_one(const struct shell *shell, uint32_t test_index); | ||
|
|
||
| /** | ||
| * @brief Dumps all ADC data from flash storage | ||
| * @param[in] shell Pointer to shell instance | ||
| * @return 0 if successful | ||
| */ | ||
| int flash_dump_all(const struct shell *shell); | ||
|
|
||
| /** | ||
| * @brief Clear all flash blocks | ||
| * @param[in] shell Pointer to shell instance | ||
| * @return 0 if successful | ||
| */ | ||
| int flash_erase_all(const struct shell *shell); | ||
|
|
||
| extern struct k_msgq storage_control_queue; | ||
|
|
||
| #endif // FLASH_STORAGE_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| CONFIG_SENSOR=y | ||
| CONFIG_SENSOR_SHELL=y | ||
| CONFIG_SPEED_OPTIMIZATIONS=y | ||
| CONFIG_SYS_CLOCK_TICKS_PER_SEC=100000 | ||
|
|
||
| CONFIG_EVENTS=y | ||
| CONFIG_BASE64=y | ||
|
|
||
| # Logging | ||
| CONFIG_LOG=y | ||
| CONFIG_LOG_MODE_IMMEDIATE=n | ||
| CONFIG_CRC=y | ||
|
|
||
| # GPIO and bus enables | ||
| CONFIG_GPIO=y | ||
| CONFIG_I2C=y | ||
| CONFIG_SPI=y | ||
| CONFIG_SPI_STM32_DMA=y | ||
|
|
||
| # ADC + sensor enables | ||
| CONFIG_ADC=y | ||
| CONFIG_ADC_LOG_LEVEL_ERR=y # Will spam annoying error at wrn level | ||
|
|
||
| CONFIG_ADC_MCP356XR=y | ||
| CONFIG_ADC_MCP356XR_THREAD_STACK_SIZE=2048 | ||
| CONFIG_ADC_MCP356XR_THREAD_PRIORITY=21 | ||
| CONFIG_INA260=y | ||
|
|
||
| CONFIG_SPI_NOR_SFDP_RUNTIME=y | ||
| CONFIG_SPI_NOR_SLEEP_ERASE_MS=10 | ||
|
|
||
| # Flash + file system | ||
| CONFIG_FLASH=y | ||
| CONFIG_FLASH_MAP=y | ||
| CONFIG_FLASH_PAGE_LAYOUT=y | ||
| CONFIG_DISK_ACCESS=y | ||
| CONFIG_FILE_SYSTEM=y | ||
|
|
||
| # Data dumping | ||
| CONFIG_SHELL=y | ||
| CONFIG_FLASH_SHELL=y | ||
| CONFIG_SHELL_BACKEND_SERIAL=y | ||
| CONFIG_UART_CONSOLE=y | ||
|
|
||
| CONFIG_SERIAL=y | ||
| CONFIG_UART_INTERRUPT_DRIVEN=y | ||
| CONFIG_CBPRINTF_FP_SUPPORT=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| sample: | ||
| description: | ||
| name: solids_board | ||
| common: | ||
| build_only: true | ||
| platform_allow: | ||
| - grim_reefer | ||
| tests: | ||
| solids_test.default: {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.