forked from dlktdr/HeadTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dlktdr#150 from dlktdr/xaio_zephyr_2.7
Merging to main. So I can work on hwfeatures branch and clean up various board specific things in the code
- Loading branch information
Showing
32 changed files
with
1,359 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "web_configurator"] | ||
path = web_configurator | ||
url = https://github.com/dlktdr/HeadTracker_WebBLE.git | ||
[submodule "firmware/src/src/LSM6DS3"] | ||
path = firmware/src/src/LSM6DS3 | ||
url = https://github.com/STMicroelectronics/LSM6DS3TR-C-PID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"build": { | ||
"arduino":{ | ||
"ldscript": "linker_script.ld" | ||
}, | ||
"core": "nRF5", | ||
"cpu": "cortex-m4", | ||
"extra_flags": "-DNRF52840_XXAA", | ||
"f_cpu": "64000000L", | ||
"hwids": [ | ||
[ | ||
"0x2886", | ||
"0x0045" | ||
], | ||
[ | ||
"0x2886", | ||
"0x8045" | ||
] | ||
], | ||
"mcu": "nrf52840", | ||
"variant": "xiao_sense", | ||
"zephyr": { | ||
"variant": "xiao_sense" | ||
}, | ||
"softdevice": { | ||
"sd_flags": "-DS140", | ||
"sd_name": "s140", | ||
"sd_version": "7.3.0", | ||
"sd_fwid": "0x0123" | ||
} | ||
}, | ||
"connectivity": [ | ||
"bluetooth" | ||
], | ||
"debug": { | ||
"jlink_device": "nRF52840_xxAA", | ||
"openocd_target": "nrf52.cfg", | ||
"svd_path": "nrf52840.svd" | ||
}, | ||
"frameworks": [ | ||
"zephyr" | ||
], | ||
"name": "XIAO Sense", | ||
"upload": { | ||
"maximum_ram_size": 262144, | ||
"maximum_size": 983040, | ||
"protocol": "sam-ba", | ||
"protocols": [ | ||
"jlink", | ||
"nrfjprog", | ||
"nrfutil", | ||
"cmsis-dap", | ||
"sam-ba", | ||
"blackmagic" | ||
], | ||
"use_1200bps_touch": true, | ||
"require_upload_port": true, | ||
"wait_for_upload_port": true | ||
}, | ||
"url": "https://wiki.seeedstudio.com/XIAO_BLE", | ||
"vendor": "Seeed Studio" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,9 @@ | |
[platformio] | ||
description = "Head Tracker" | ||
# default_envs = Head_Tracker-Nano33_BLE | ||
# default_envs = Head_Tracker-Nano33_BLE_Sense_Rev_2 | ||
# default_envs = Head_Tracker-DTQSys | ||
# default_envs = Head_Tracker-Nano33_BLE_Sense2 | ||
# default_envs = Head_Tracker-XIAOSense | ||
|
||
[common] | ||
build_flags = | ||
|
@@ -87,6 +88,17 @@ | |
-DPCB_DTQSYS=y | ||
-DFNAME=DTQ | ||
|
||
|
||
|
||
|
||
# Zephyr OS + XAIO Sense | ||
[env:Head_Tracker-XIAOSense] | ||
#build_type = debug | ||
extends = nrf52common | ||
platform = [email protected] | ||
board = xiao_sense | ||
framework = zephyr | ||
lib_deps = bblanchon/[email protected] | ||
debug_tool = jlink | ||
build_flags = | ||
${common.build_flags} | ||
-DRTOS_ZEPHYR=y | ||
-DPCB_XIAOSENSE=y | ||
-DFNAME=XIA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <zephyr.h> | ||
|
||
#include "io.h" | ||
#include "lsm_common.h" | ||
#include "defines.h" | ||
|
||
int32_t platform_read_lsm6(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len) | ||
{ | ||
const struct device *i2c_dev = device_get_binding("I2C_1"); | ||
return i2c_burst_read(i2c_dev, LSM6DS3TR_C_ID, reg, bufp, len); | ||
} | ||
|
||
int32_t platform_write_lsm6(void *handle, uint8_t reg, const uint8_t *bufp, uint16_t len) | ||
{ | ||
const struct device *i2c_dev = device_get_binding("I2C_1"); | ||
return i2c_burst_write(i2c_dev, LSM6DS3TR_C_ID, reg, bufp, len); | ||
} | ||
|
||
int initailizeLSM6DS3(stmdev_ctx_t *dev_ctx) | ||
{ | ||
uint8_t whoamI=0, rst; | ||
/* Initialize mems driver interface */ | ||
dev_ctx->write_reg = platform_write_lsm6; | ||
dev_ctx->read_reg = platform_read_lsm6; | ||
/* Wait sensor boot time */ | ||
k_msleep(BOOT_TIME); | ||
/* Check device ID */ | ||
lsm6ds3tr_c_device_id_get(dev_ctx, &whoamI); | ||
if (whoamI != LSM6DS3TR_C_ID) | ||
return -1; | ||
/* Restore default configuration */ | ||
lsm6ds3tr_c_reset_set(dev_ctx, PROPERTY_ENABLE); | ||
do { | ||
lsm6ds3tr_c_reset_get(dev_ctx, &rst); | ||
} while (rst); | ||
/* Enable Block Data Update */ | ||
lsm6ds3tr_c_block_data_update_set(dev_ctx, PROPERTY_ENABLE); | ||
/* Set full scale */ | ||
lsm6ds3tr_c_xl_full_scale_set(dev_ctx, LSM6DS3TR_C_2g); | ||
lsm6ds3tr_c_gy_full_scale_set(dev_ctx, LSM6DS3TR_C_2000dps); | ||
/* Set Output Data Rate for Acc and Gyro */ | ||
lsm6ds3tr_c_xl_data_rate_set(dev_ctx, LSM6DS3TR_C_XL_ODR_208Hz); | ||
lsm6ds3tr_c_gy_data_rate_set(dev_ctx, LSM6DS3TR_C_GY_ODR_208Hz); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include <drivers/i2c.h> | ||
#include <zephyr.h> | ||
|
||
#include "LSM6DS3/lsm6ds3tr-c_reg.h" | ||
|
||
#define BOOT_TIME 30 | ||
|
||
int32_t platform_read_lsm6(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len); | ||
int32_t platform_write_lsm6(void *handle, uint8_t reg, const uint8_t *bufp, uint16_t len); | ||
int initailizeLSM6DS3(stmdev_ctx_t *dev_ctx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
#include "boardsdefs.h" | ||
|
||
// Pull up pin mode | ||
#define INPUT_PULLUP (GPIO_INPUT | GPIO_PULL_UP) | ||
|
||
// Board Features | ||
#define HAS_3DIODE_RGB | ||
#define HAS_NOTIFYLED | ||
#define HAS_LSM6DS3 | ||
#define HAS_CENTERBTN | ||
|
||
// Mapping Analog numbers to Analog pins | ||
#define AN0 7 // Battery Voltage | ||
#define AN1 1 // | ||
#define AN2 4 // | ||
#define AN3 5 // | ||
|
||
// Pins (name, number, description) | ||
// NOTE: These pins are an enum entry. e.g. IO_D2 = 0 | ||
// - Use PIN_NAME_TO_NUM(IO_D2) to get actual the pin number | ||
// - The pin number can be converted back into the NRF port/pin | ||
// using functions PIN_TO_NRFPORT & PIN_TO_NRFPIN | ||
// - The string descrition for D2 would be StrPins[IO_D2] | ||
|
||
#define PIN_X \ | ||
PIN(AN0, NRFPIN(0, 31), "Analog Battery Voltage") \ | ||
PIN(ANBATT_ENA, NRFPIN(0, 14), "Battery Monitor Enable") \ | ||
PIN(AN1, NRFPIN(0, 3), "Analog 1 (AIN_1)") \ | ||
PIN(AN2, NRFPIN(0, 28), "Analog 2 (AIN_4)") \ | ||
PIN(AN3, NRFPIN(0, 29), "Analog 3 (AIN_5)") \ | ||
PIN(CENTER_BTN, NRFPIN(1, 13), "Center Button, D8") \ | ||
PIN(LEDR, NRFPIN(0, 26), "Red LED") \ | ||
PIN(LEDG, NRFPIN(0, 30), "Green LED") \ | ||
PIN(LEDB, NRFPIN(0, 6), "Blue LED") \ | ||
PIN(LED, NRFPIN(0, 14), "Notification LED") \ | ||
PIN(PPMOUT, NRFPIN(1, 15), "PPM Output Pin [D10]") \ | ||
PIN(PPMIN, NRFPIN(1, 14), "PPM In Pin [D9]") \ | ||
PIN(TX, NRFPIN(1, 11), "UART Transmit [TX]") \ | ||
PIN(RX, NRFPIN(1, 12), "UART Receive [RX]") \ | ||
PIN(TXINV, NRFPIN(0, 19), "UART TX, Inv Pin") \ | ||
PIN(RXINVO, NRFPIN(0, 10), "UART RX, Out Inv") \ | ||
PIN(RXINVI, NRFPIN(0, 9), "UART RX, Inp Inv") \ | ||
PIN(SCK, NRFPIN(0, 21), "SPI Clock - Flash") \ | ||
PIN(MOSI, NRFPIN(0, 20), "SPI Data Out - Flash") \ | ||
PIN(MISO, NRFPIN(0, 24), "SPI Data In - Flash") \ | ||
PIN(FLSH_WP, NRFPIN(0, 22), "Flash Write Protect") \ | ||
PIN(FLSH_HLD, NRFPIN(0, 23), "Flash Hold") \ | ||
PIN(LSM6DS3PWR, NRFPIN(1, 8), "LSM6DS3 Power 6DPWR") \ | ||
PIN(LSM6DS3INT, NRFPIN(0, 11), "LSM6DS3 Interrupt") \ | ||
PIN(I2CSCL, NRFPIN(0, 27), "I2C - SCL") \ | ||
PIN(I2CSDA, NRFPIN(0, 7), "I2C - SDA") \ | ||
END_IO_PINS \ | ||
|
||
typedef enum { | ||
#define PIN(NAME, PINNO, DESC) IO_##NAME, | ||
PIN_X | ||
#undef PIN | ||
} pins_e; | ||
|
||
const int8_t PinNumber[] = { | ||
#define PIN(NAME, PINNO, DESC) PINNO, | ||
PIN_X | ||
#undef PIN | ||
}; | ||
|
||
// Required pin setting functions | ||
#define pinMode(pin, mode) gpio_pin_configure(gpios[PIN_TO_NRFPORT(PIN_NAME_TO_NUM(pin))], PIN_TO_NRFPIN(PIN_NAME_TO_NUM(pin)), mode) | ||
#define digitalWrite(pin, value) gpio_pin_set(gpios[PIN_TO_NRFPORT(PIN_NAME_TO_NUM(pin))], PIN_TO_NRFPIN(PIN_NAME_TO_NUM(pin)), value) | ||
#define digitalRead(pin) gpio_pin_get(gpios[PIN_TO_NRFPORT(PIN_NAME_TO_NUM(pin))], PIN_TO_NRFPIN(PIN_NAME_TO_NUM(pin))) | ||
|
||
// TODO Find good values here | ||
// Values below were determined by plotting Gyro Output (See sense.cpp, gyroCalibration()) | ||
#define GYRO_STABLE_DIFF 200.0f | ||
#define ACC_STABLE_DIFF 2.5f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.