├── .gitignore ├── LICENSE ├── README.md ├── ble_peripheral ├── ble_app_hids_joystick_md612 │ ├── Readme.md │ ├── config │ │ └── advertising_config.h │ ├── hex │ │ └── ble_app_hids_joystick_md612_pesky_s132.hex │ ├── main.c │ ├── md612.c │ ├── md612.h │ └── pesky │ │ └── s132 │ │ ├── armgcc │ │ ├── Makefile │ │ └── ble_app_hids_joystick_md612_gcc_nrf52.ld │ │ └── config │ │ └── sdk_config.h ├── ble_app_hids_mouse │ ├── Readme.md │ ├── hex │ │ └── ble_app_hids_mouse_pesky_s132.hex │ └── pesky │ │ └── s132 │ │ ├── armgcc │ │ ├── Makefile │ │ └── ble_app_hids_mouse_gcc_nrf52.ld │ │ └── config │ │ └── sdk_config.h ├── ble_app_hids_mouse_md612 │ ├── Readme.md │ ├── config │ │ └── advertising_config.h │ ├── hex │ │ └── ble_app_hids_mouse_md612_pesky_s132.hex │ ├── main.c │ ├── md612.c │ ├── md612.h │ └── pesky │ │ └── s132 │ │ ├── armgcc │ │ ├── Makefile │ │ └── ble_app_hids_mouse_md612_gcc_nrf52.ld │ │ └── config │ │ └── sdk_config.h └── ble_app_uart │ ├── Readme.md │ ├── hex │ └── ble_app_uart_pesky_s132.hex │ └── pesky │ └── s132 │ ├── armgcc │ ├── Makefile │ └── ble_app_uart_gcc_nrf52.ld │ └── config │ └── sdk_config.h ├── common ├── custom_board.h ├── inv_pesky.h ├── timestamping.c └── timestamping.h ├── external ├── BMP280_driver │ ├── README.md │ ├── bmp280.c │ ├── bmp280.h │ └── bmp280_support.c └── motion_driver_6.12 │ ├── core │ ├── driver │ │ ├── eMPL │ │ │ ├── dmpKey.h │ │ │ ├── dmpmap.h │ │ │ ├── inv_mpu.c │ │ │ ├── inv_mpu.h │ │ │ ├── inv_mpu_dmp_motion_driver.c │ │ │ └── inv_mpu_dmp_motion_driver.h │ │ ├── include │ │ │ ├── log.h │ │ │ ├── mlinclude.h │ │ │ ├── mlmath.h │ │ │ ├── mlos.h │ │ │ ├── mltypes.h │ │ │ ├── mpu.h │ │ │ └── stdint_invensense.h │ │ └── nRF5 │ │ │ ├── log_nRF5.c │ │ │ └── packet.h │ ├── eMPL-hal │ │ ├── eMPL_outputs.c │ │ └── eMPL_outputs.h │ ├── mllite │ │ ├── data_builder.c │ │ ├── data_builder.h │ │ ├── hal_outputs.c │ │ ├── hal_outputs.h │ │ ├── invensense.h │ │ ├── message_layer.c │ │ ├── message_layer.h │ │ ├── ml_math_func.c │ │ ├── ml_math_func.h │ │ ├── mlmath.c │ │ ├── mpl.c │ │ ├── mpl.h │ │ ├── results_holder.c │ │ ├── results_holder.h │ │ ├── start_manager.c │ │ ├── start_manager.h │ │ ├── storage_manager.c │ │ └── storage_manager.h │ └── mpl │ │ ├── accel_auto_cal.h │ │ ├── compass_vec_cal.h │ │ ├── fast_no_motion.h │ │ ├── fusion_9axis.h │ │ ├── gyro_tc.h │ │ ├── heading_from_gyro.h │ │ ├── inv_math.h │ │ ├── invensense_adv.h │ │ ├── mag_disturb.h │ │ ├── motion_no_motion.h │ │ ├── no_gyro_fusion.h │ │ └── quaternion_supervisor.h │ ├── core_orig │ ├── driver │ │ ├── eMPL │ │ │ ├── dmpKey.h │ │ │ ├── dmpmap.h │ │ │ ├── inv_mpu.c │ │ │ ├── inv_mpu.h │ │ │ ├── inv_mpu_dmp_motion_driver.c │ │ │ └── inv_mpu_dmp_motion_driver.h │ │ ├── include │ │ │ ├── log.h │ │ │ ├── mlinclude.h │ │ │ ├── mlmath.h │ │ │ ├── mlos.h │ │ │ ├── mltypes.h │ │ │ ├── mpu.h │ │ │ └── stdint_invensense.h │ │ └── stm32L │ │ │ ├── log_stm32.c │ │ │ └── packet.h │ ├── eMPL-hal │ │ ├── eMPL_outputs.c │ │ └── eMPL_outputs.h │ ├── mllite │ │ ├── data_builder.c │ │ ├── data_builder.h │ │ ├── hal_outputs.c │ │ ├── hal_outputs.h │ │ ├── invensense.h │ │ ├── message_layer.c │ │ ├── message_layer.h │ │ ├── ml_math_func.c │ │ ├── ml_math_func.h │ │ ├── mlmath.c │ │ ├── mpl.c │ │ ├── mpl.h │ │ ├── results_holder.c │ │ ├── results_holder.h │ │ ├── start_manager.c │ │ ├── start_manager.h │ │ ├── storage_manager.c │ │ └── storage_manager.h │ └── mpl │ │ ├── accel_auto_cal.h │ │ ├── compass_vec_cal.h │ │ ├── fast_no_motion.h │ │ ├── fusion_9axis.h │ │ ├── gyro_tc.h │ │ ├── heading_from_gyro.h │ │ ├── inv_math.h │ │ ├── invensense_adv.h │ │ ├── mag_disturb.h │ │ ├── motion_no_motion.h │ │ ├── no_gyro_fusion.h │ │ └── quaternion_supervisor.h │ ├── eMPL-pythonclient │ ├── eMPL-client.py │ ├── euclid.py │ └── ponycube.py │ ├── eMPL-pythonclient_orig │ ├── eMPL-client.py │ ├── euclid.py │ └── ponycube.py │ └── emd 6.1.2 release note.txt ├── peripheral ├── blinky │ ├── hex │ │ ├── blinky_pesky_blank.hex │ │ └── blinky_pesky_s132.hex │ ├── main.c │ └── pesky │ │ ├── blank │ │ ├── armgcc │ │ │ ├── Makefile │ │ │ └── blinky_gcc_nrf52.ld │ │ └── config │ │ │ └── sdk_config.h │ │ └── s132 │ │ ├── armgcc │ │ ├── Makefile │ │ └── blinky_gcc_nrf52.ld │ │ └── config │ │ └── sdk_config.h ├── bmp280 │ ├── README.md │ ├── hex │ │ └── bmp280_pesky_blank.hex │ ├── main.c │ └── pesky │ │ └── blank │ │ ├── armgcc │ │ ├── Makefile │ │ └── bmp280_gcc_nrf52.ld │ │ └── config │ │ └── sdk_config.h ├── md612 │ ├── README.md │ ├── hex │ │ └── md612_pesky_blank.hex │ ├── main.c │ └── pesky │ │ └── blank │ │ ├── armgcc │ │ ├── Makefile │ │ └── md612_gcc_nrf52.ld │ │ └── config │ │ └── sdk_config.h ├── mpu9250 │ ├── README.md │ ├── hex │ │ └── mpu9250_pesky_blank.hex │ ├── main.c │ └── pesky │ │ └── blank │ │ ├── armgcc │ │ ├── Makefile │ │ └── mpu9250_gcc_nrf52.ld │ │ └── config │ │ └── sdk_config.h ├── pin_change_int │ ├── README.md │ ├── hex │ │ └── pin_change_int_pesky_blank.hex │ ├── main.c │ └── pesky │ │ └── blank │ │ ├── armgcc │ │ ├── Makefile │ │ └── pin_change_int_gcc_nrf52.ld │ │ └── config │ │ └── sdk_config.h ├── twi_master_using_app_twi │ ├── README.md │ ├── hex │ │ └── twi_master_using_app_twi_pesky_blank.hex │ ├── main.c │ └── pesky │ │ └── blank │ │ ├── armgcc │ │ ├── Makefile │ │ └── twi_master_using_app_twi_gcc_nrf52.ld │ │ └── config │ │ └── sdk_config.h └── uart │ ├── README.md │ ├── hex │ └── uart_pesky_blank.hex │ ├── main.c │ └── pesky │ └── blank │ ├── armgcc │ ├── Makefile │ └── uart_gcc_nrf52.ld │ └── config │ └── sdk_config.h ├── prepare_hex.sh └── segger └── rtt ├── README.md ├── hex ├── rtt_pesky_blank.hex └── rtt_pesky_s132.hex ├── main.c └── pesky ├── blank ├── armgcc │ ├── Makefile │ └── rtt_gcc_nrf52.ld └── config │ └── sdk_config.h └── s132 ├── armgcc ├── Makefile └── rtt_gcc_nrf52.ld └── config └── sdk_config.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | 30 | # Debug files 31 | *.dSYM/ 32 | *.su 33 | 34 | # Python 35 | *.pyc 36 | 37 | # Build folders 38 | _build/ 39 | 40 | # Other 41 | video/ 42 | peripheral/martinsbl/ 43 | peripheral/nrf5-mpu-data-ready-interrupts/ 44 | peripheral/nrf5-mpu-simple/ 45 | logic-analyser/ 46 | non-git/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 e27182 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ble_peripheral/ble_app_hids_joystick_md612/Readme.md: -------------------------------------------------------------------------------- 1 | # BLE: HID Joystick 2 | 3 | ![ble_app_hids_joystick_md612](https://cloud.githubusercontent.com/assets/14309815/24084556/fed7d74e-0cf4-11e7-8a1b-c86b68064d26.gif) 4 | 5 | Adapted from ble_app_hids_mouse_md612 example. 6 | 7 | After flashing you should see board as "Nordic_Joystick" with gamepad icon on your phone/tablet/PC. 8 | 9 | Code contains same hardcoded calibration parameters as mouse example. 10 | 'Self-test' routine executes on startup to recalibrate accel and gyro, so, please, align board horizontally on startup to get correct calibration. 11 | If you wish to calibrate magnetometer, you should do good '8' figure along with rotations on each axis (X, -X, Y, -Y, Z, -Z) and Invensense's implementation will update calibration for magnetometer automagically. 12 | 13 | Also tested with GamePad API in Google Chrome. 14 | -------------------------------------------------------------------------------- /ble_peripheral/ble_app_hids_joystick_md612/config/advertising_config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @cond To make doxygen skip this file */ 14 | 15 | /** @file 16 | * This header contains defines with respect persistent storage that are specific to 17 | * persistent storage implementation and application use case. 18 | */ 19 | #ifndef ADVERTISING_CONFIG_H__ 20 | #define ADVERTISING_CONFIG_H__ 21 | 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | //#define APP_ADV_INTERVAL_FAST 0x0028 /**< Fast advertising interval (in units of 0.625 ms. This value corresponds to 25 ms.). */ 29 | //#define APP_ADV_INTERVAL_SLOW 0x0C80 /**< Slow advertising interval (in units of 0.625 ms. This value corrsponds to 2 seconds). */ 30 | // 31 | //#define APP_ADV_FAST_TIMEOUT 30 /**< The duration of the fast advertising period (in seconds). */ 32 | //#define APP_ADV_SLOW_TIMEOUT 180 /**< The duration of the slow advertising period (in seconds). */ 33 | //#define APP_ADV_WHITELIST_TIMEOUT 30 34 | // 35 | //#define APP_ADV_DIRECTED_TIMEOUT 5 /**< Number of direct advertisement (each lasting 1.28seconds). */ 36 | // 37 | //#define APP_ADV_USE_DIRECTED 1 38 | //#define APP_ADV_USE_FAST 1 39 | //#define APP_ADV_USE_SLOW 1 40 | //#define APP_ADV_USE_WHITELIST 1 /**< Set to True if white list will be used, false if not. */ 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif // ADVERTISING_CONFIG_H__ 48 | 49 | /** @} */ 50 | /** @endcond */ 51 | -------------------------------------------------------------------------------- /ble_peripheral/ble_app_hids_joystick_md612/md612.h: -------------------------------------------------------------------------------- 1 | #ifndef __MD612__ 2 | #define __MD612__ 3 | 4 | #include "nrf_drv_gpiote.h" 5 | 6 | /* Platform-specific information. Kinda like a boardfile. */ 7 | typedef struct { 8 | void (*cb) (unsigned char type, long *data, int8_t accuracy, unsigned long timestamp, unsigned short tap); 9 | signed char gyro_orientation[9]; 10 | signed char compass_orientation[9]; 11 | nrf_drv_gpiote_pin_t pin; 12 | } platform_data_t; 13 | 14 | void md612_configure(platform_data_t const * platform_data); 15 | void md612_selftest(); 16 | void md612_beforesleep(); 17 | void md612_aftersleep(); 18 | unsigned char md612_hasnewdata(); 19 | 20 | #endif -------------------------------------------------------------------------------- /ble_peripheral/ble_app_hids_joystick_md612/pesky/s132/armgcc/ble_app_hids_joystick_md612_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000 9 | RAM (rwx) : ORIGIN = 0x20002128, LENGTH = 0xded8 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /ble_peripheral/ble_app_hids_mouse/Readme.md: -------------------------------------------------------------------------------- 1 | # BLE: HID Mouse 2 | 3 | Adaptation of ble_app_hids_mouse example from Nordic Semi SDK. It reuses source code from original folder in SDK, just Makefile is adapted. 4 | 5 | After flashing you should see board as "Nordic_Mouse" with mouse icon on your phone/tablet/PC. 6 | 7 | When connecting BSP buttons/pins 8,9,11,12 to GND mouse cursor should appear on the screen and move in some direction. 8 | 9 | Please, see video below: 10 | 11 | ![image](https://cloud.githubusercontent.com/assets/14309815/19699503/3f0e2720-9afc-11e6-8937-3b85e9b43c4e.gif) -------------------------------------------------------------------------------- /ble_peripheral/ble_app_hids_mouse/pesky/s132/armgcc/ble_app_hids_mouse_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000 9 | RAM (rwx) : ORIGIN = 0x20002128, LENGTH = 0xded8 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /ble_peripheral/ble_app_hids_mouse_md612/Readme.md: -------------------------------------------------------------------------------- 1 | # BLE: HID Mouse + MD 6.12 2 | 3 | Update 09.02.2017: added support of taps (see 2nd video below) 4 | 5 | ![image](https://cloud.githubusercontent.com/assets/14309815/22438204/bef53b62-e733-11e6-9408-a8c41516bd13.gif) 6 | 7 | ![ble_app_hids_mouse_md612 buttons](https://cloud.githubusercontent.com/assets/14309815/22778568/16032188-eec0-11e6-97be-2b5ea431b305.gif) 8 | 9 | Adapted ble_app_hids_mouse example from Nordic Semi SDK + adapted Motion Driver 6.12 from Invensense. 10 | 11 | After flashing you should see board as "Nordic_Mouse" with mouse icon on your phone/tablet/PC. 12 | 13 | Code contains hardcoded calibration parameters adapted to my environment: 14 | 15 | ```C 16 | long bias[3]; 17 | bias[0] = 6211584; 18 | bias[1] = -2068480; 19 | bias[2] = -2611200; 20 | inv_set_accel_bias(bias, 3); 21 | bias[0] = -748747; 22 | bias[1] = 1786825; 23 | bias[2] = 1045736; 24 | inv_set_gyro_bias(bias, 3); 25 | bias[0] = -10261884; 26 | bias[1] = 63218332; 27 | bias[2] = -29328029; 28 | inv_set_compass_bias(bias, 3); 29 | ``` 30 | 31 | To get this values I extended MD612 example from this repository, so that when pressing 'b' - it prints all calculated bias values for each sensor. 32 | Also 'self-test' routine executes on startup to recalibrate accel and gyro, so, please, align board horizontally on startup to get correct calibration. 33 | If you wish to calibrate magnetometer, you should do good '8' figure along with rotations on each axis (X, -X, Y, -Y, Z, -Z) and Invensense's implementation will update calibration for magnetometer automagically. 34 | 35 | Overall stability with calibrated sensors is very good, but sometimes I see a freeze for a second. As for now, I'm not sure what is the cause of it. 36 | 37 | Part of the code taken from MD612 example is commented out as now we have stack overflow issues, so be careful when extending it. 38 | -------------------------------------------------------------------------------- /ble_peripheral/ble_app_hids_mouse_md612/config/advertising_config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @cond To make doxygen skip this file */ 14 | 15 | /** @file 16 | * This header contains defines with respect persistent storage that are specific to 17 | * persistent storage implementation and application use case. 18 | */ 19 | #ifndef ADVERTISING_CONFIG_H__ 20 | #define ADVERTISING_CONFIG_H__ 21 | 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | //#define APP_ADV_INTERVAL_FAST 0x0028 /**< Fast advertising interval (in units of 0.625 ms. This value corresponds to 25 ms.). */ 29 | //#define APP_ADV_INTERVAL_SLOW 0x0C80 /**< Slow advertising interval (in units of 0.625 ms. This value corrsponds to 2 seconds). */ 30 | // 31 | //#define APP_ADV_FAST_TIMEOUT 30 /**< The duration of the fast advertising period (in seconds). */ 32 | //#define APP_ADV_SLOW_TIMEOUT 180 /**< The duration of the slow advertising period (in seconds). */ 33 | //#define APP_ADV_WHITELIST_TIMEOUT 30 34 | // 35 | //#define APP_ADV_DIRECTED_TIMEOUT 5 /**< Number of direct advertisement (each lasting 1.28seconds). */ 36 | // 37 | //#define APP_ADV_USE_DIRECTED 1 38 | //#define APP_ADV_USE_FAST 1 39 | //#define APP_ADV_USE_SLOW 1 40 | //#define APP_ADV_USE_WHITELIST 1 /**< Set to True if white list will be used, false if not. */ 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif // ADVERTISING_CONFIG_H__ 48 | 49 | /** @} */ 50 | /** @endcond */ 51 | -------------------------------------------------------------------------------- /ble_peripheral/ble_app_hids_mouse_md612/md612.h: -------------------------------------------------------------------------------- 1 | #ifndef __MD612__ 2 | #define __MD612__ 3 | 4 | #include "nrf_drv_gpiote.h" 5 | 6 | /* Platform-specific information. Kinda like a boardfile. */ 7 | typedef struct { 8 | void (*cb) (unsigned char type, long *data, int8_t accuracy, unsigned long timestamp, unsigned short tap); 9 | signed char gyro_orientation[9]; 10 | signed char compass_orientation[9]; 11 | nrf_drv_gpiote_pin_t pin; 12 | } platform_data_t; 13 | 14 | void md612_configure(platform_data_t const * platform_data); 15 | void md612_selftest(); 16 | void md612_beforesleep(); 17 | void md612_aftersleep(); 18 | unsigned char md612_hasnewdata(); 19 | 20 | #endif -------------------------------------------------------------------------------- /ble_peripheral/ble_app_hids_mouse_md612/pesky/s132/armgcc/ble_app_hids_mouse_md612_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000 9 | RAM (rwx) : ORIGIN = 0x20002128, LENGTH = 0xded8 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /ble_peripheral/ble_app_uart/Readme.md: -------------------------------------------------------------------------------- 1 | # BLE: HID UART 2 | 3 | Adaptation of ble_app_uart example from Nordic Semi SDK. It reuses source code from original folder in SDK, just Makefile is adapted. 4 | 5 | After flashing you should be able to connect to your board with "nRF Toolbox" app from App Store (on Android, I beleave there exists similar app for iOS from Nordic Semiconductor), 6 | and use UART mode to talk to the board via BLE. Messages will be forwarded to board's UART. 7 | 8 | Please, see video below: 9 | 10 | ![image](https://cloud.githubusercontent.com/assets/14309815/19699502/3f0c7682-9afc-11e6-80f5-18a5873445f2.gif) -------------------------------------------------------------------------------- /ble_peripheral/ble_app_uart/pesky/s132/armgcc/ble_app_uart_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000 9 | RAM (rwx) : ORIGIN = 0x20002128, LENGTH = 0xded8 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /common/custom_board.h: -------------------------------------------------------------------------------- 1 | #ifndef NRF52_PESKY_H 2 | #define NRF52_PESKY_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | // LEDs definitions 9 | #define LEDS_NUMBER 3 10 | 11 | #define LED_1 22 12 | #define LED_2 23 13 | #define LED_3 24 14 | 15 | #define LEDS_LIST { LED_1, LED_2, LED_3 } 16 | 17 | #define BSP_LED_0 LED_1 18 | #define BSP_LED_1 LED_2 19 | #define BSP_LED_2 LED_3 20 | 21 | #define BSP_LED_0_MASK (1<pin, &config, int_param->cb)); 80 | nrf_drv_gpiote_in_event_enable(int_param->pin, true); 81 | 82 | return 0; 83 | } 84 | 85 | #define __no_operation __NOP 86 | 87 | #endif // _INV_PESKY_ -------------------------------------------------------------------------------- /common/timestamping.c: -------------------------------------------------------------------------------- 1 | #include "timestamping.h" 2 | #include "nrf_drv_clock.h" 3 | #include "app_timer.h" 4 | 5 | void lfclk_config(void) 6 | { 7 | uint32_t err_code; 8 | 9 | err_code = nrf_drv_clock_init(); 10 | APP_ERROR_CHECK(err_code); 11 | 12 | nrf_drv_clock_lfclk_request(NULL); 13 | } 14 | 15 | uint32_t ticks_from = 0; 16 | uint32_t timestamp_ms = 0; 17 | 18 | uint32_t timestamp_func(void) { 19 | uint32_t ticks_diff = 0; 20 | uint32_t ms_diff = 0; 21 | uint32_t ticks_to = NRF_RTC0->COUNTER; //app_timer_cnt_get(); 22 | 23 | APP_ERROR_CHECK(app_timer_cnt_diff_compute(ticks_to, ticks_from, &ticks_diff)); 24 | ticks_from = ticks_to; 25 | 26 | ms_diff = APP_TIMER_MS(ticks_diff, APP_TIMER_PRESCALER); 27 | 28 | timestamp_ms += ms_diff; 29 | 30 | return timestamp_ms; 31 | } -------------------------------------------------------------------------------- /common/timestamping.h: -------------------------------------------------------------------------------- 1 | #ifndef _TIMESTAMPING_ 2 | #define _TIMESTAMPING_ 3 | 4 | #include 5 | 6 | #define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */ 7 | #define APP_TIMER_OP_QUEUE_SIZE 4 /**< Size of timer operation queues. */ 8 | #define APP_TIMER_MS(TICKS, PRESCALER)\ 9 | ((uint32_t)ROUNDED_DIV((TICKS) * ((PRESCALER) + 1) * 1000, (uint64_t)APP_TIMER_CLOCK_FREQ)) 10 | 11 | void lfclk_config(void); 12 | uint32_t timestamp_func(void); 13 | 14 | #endif // _TIMESTAMPING_ -------------------------------------------------------------------------------- /external/BMP280_driver/README.md: -------------------------------------------------------------------------------- 1 | 2 | CONTENTS OF THIS FILE 3 | ======================= 4 | * Introduction 5 | * Version 6 | * Integration details 7 | * Driver files information 8 | * Supported sensor interface 9 | * Copyright 10 | 11 | 12 | INTRODUCTION 13 | =============== 14 | - This package contains the Bosch Sensortec MEMS pressure sensor driver (sensor API) 15 | - The sensor driver package includes bmp280.h, bmp280.c and bmp280_support.c files 16 | 17 | VERSION 18 | ========= 19 | - Version of bmp280 sensor driver is: 20 | * bmp280.c - V2.0.5 21 | * bmp280.h - V2.0.5 22 | * bmp280_support.c - V1.0.6 23 | 24 | INTEGRATION DETAILS 25 | ===================== 26 | - Integrate bmp280.h and bmp280.c file in to your project. 27 | - The bmp280_support.c file contains only examples for API use cases, so it is not required to integrate into project. 28 | 29 | DRIVER FILES INFORMATION 30 | =========================== 31 | bmp280.h 32 | ----------- 33 | * This header file has the register address definition, constant definitions, data type definition and supported sensor driver calls declarations. 34 | 35 | bmp280.c 36 | ------------ 37 | * This file contains the implementation for the sensor driver APIs. 38 | 39 | bmp280_support.c 40 | ---------------------- 41 | * This file shall be used as an user guidance, here you can find samples of 42 | * Initialize the sensor with I2C/SPI communication 43 | - Add your code to the SPI and/or I2C bus read and bus write functions. 44 | - Return value can be chosen by yourself 45 | - API just passes that value to your application code 46 | - Add your code to the delay function 47 | - Change I2C address accordingly in bmp280.h 48 | * Power mode configuration of the sensor 49 | * Get and set functions usage 50 | * Reading the sensor read out data 51 | 52 | SUPPORTED SENSOR INTERFACE 53 | ==================================== 54 | - This pressure sensor driver supports I2C and SPI interfaces 55 | 56 | 57 | COPYRIGHT 58 | =========== 59 | - Copyright (C) 2012 - 2016 Bosch Sensortec GmbH 60 | 61 | 62 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/driver/eMPL/inv_mpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /** 8 | * @addtogroup DRIVERS Sensor Driver Layer 9 | * @brief Hardware drivers to communicate with sensors via I2C. 10 | * 11 | * @{ 12 | * @file inv_mpu.h 13 | * @brief An I2C-based driver for Invensense gyroscopes. 14 | * @details This driver currently works for the following devices: 15 | * MPU6050 16 | * MPU6500 17 | * MPU9150 (or MPU6050 w/ AK8975 on the auxiliary bus) 18 | * MPU9250 (or MPU6500 w/ AK8963 on the auxiliary bus) 19 | */ 20 | 21 | #ifndef _INV_MPU_H_ 22 | #define _INV_MPU_H_ 23 | 24 | #define INV_X_GYRO (0x40) 25 | #define INV_Y_GYRO (0x20) 26 | #define INV_Z_GYRO (0x10) 27 | #define INV_XYZ_GYRO (INV_X_GYRO | INV_Y_GYRO | INV_Z_GYRO) 28 | #define INV_XYZ_ACCEL (0x08) 29 | #define INV_XYZ_COMPASS (0x01) 30 | 31 | #if defined NRF52 32 | #include "nrf_drv_gpiote.h" 33 | #endif 34 | 35 | struct int_param_s { 36 | #if defined EMPL_TARGET_MSP430 || defined MOTION_DRIVER_TARGET_MSP430 37 | void (*cb)(void); 38 | unsigned short pin; 39 | unsigned char lp_exit; 40 | unsigned char active_low; 41 | #elif defined EMPL_TARGET_UC3L0 42 | unsigned long pin; 43 | void (*cb)(volatile void*); 44 | void *arg; 45 | #elif defined EMPL_TARGET_STM32F4 46 | void (*cb)(void); 47 | #elif defined NRF52 48 | nrf_drv_gpiote_pin_t pin; 49 | nrf_drv_gpiote_evt_handler_t cb; 50 | #endif 51 | }; 52 | 53 | #define MPU_INT_STATUS_DATA_READY (0x0001) 54 | #define MPU_INT_STATUS_DMP (0x0002) 55 | #define MPU_INT_STATUS_PLL_READY (0x0004) 56 | #define MPU_INT_STATUS_I2C_MST (0x0008) 57 | #define MPU_INT_STATUS_FIFO_OVERFLOW (0x0010) 58 | #define MPU_INT_STATUS_ZMOT (0x0020) 59 | #define MPU_INT_STATUS_MOT (0x0040) 60 | #define MPU_INT_STATUS_FREE_FALL (0x0080) 61 | #define MPU_INT_STATUS_DMP_0 (0x0100) 62 | #define MPU_INT_STATUS_DMP_1 (0x0200) 63 | #define MPU_INT_STATUS_DMP_2 (0x0400) 64 | #define MPU_INT_STATUS_DMP_3 (0x0800) 65 | #define MPU_INT_STATUS_DMP_4 (0x1000) 66 | #define MPU_INT_STATUS_DMP_5 (0x2000) 67 | 68 | /* Set up APIs */ 69 | int mpu_init(struct int_param_s *int_param); 70 | int mpu_init_slave(void); 71 | int mpu_set_bypass(unsigned char bypass_on); 72 | 73 | /* Configuration APIs */ 74 | int mpu_lp_accel_mode(unsigned short rate); 75 | int mpu_lp_motion_interrupt(unsigned short thresh, unsigned char time, 76 | unsigned short lpa_freq); 77 | int mpu_set_int_level(unsigned char active_low); 78 | int mpu_set_int_latched(unsigned char enable); 79 | 80 | int mpu_set_dmp_state(unsigned char enable); 81 | int mpu_get_dmp_state(unsigned char *enabled); 82 | 83 | int mpu_get_lpf(unsigned short *lpf); 84 | int mpu_set_lpf(unsigned short lpf); 85 | 86 | int mpu_get_gyro_fsr(unsigned short *fsr); 87 | int mpu_set_gyro_fsr(unsigned short fsr); 88 | 89 | int mpu_get_accel_fsr(unsigned char *fsr); 90 | int mpu_set_accel_fsr(unsigned char fsr); 91 | 92 | int mpu_get_compass_fsr(unsigned short *fsr); 93 | 94 | int mpu_get_gyro_sens(float *sens); 95 | int mpu_get_accel_sens(unsigned short *sens); 96 | 97 | int mpu_get_sample_rate(unsigned short *rate); 98 | int mpu_set_sample_rate(unsigned short rate); 99 | int mpu_get_compass_sample_rate(unsigned short *rate); 100 | int mpu_set_compass_sample_rate(unsigned short rate); 101 | 102 | int mpu_get_fifo_config(unsigned char *sensors); 103 | int mpu_configure_fifo(unsigned char sensors); 104 | 105 | int mpu_get_power_state(unsigned char *power_on); 106 | int mpu_set_sensors(unsigned char sensors); 107 | 108 | int mpu_read_6500_accel_bias(long *accel_bias); 109 | int mpu_set_gyro_bias_reg(long * gyro_bias); 110 | int mpu_set_accel_bias_6500_reg(const long *accel_bias); 111 | int mpu_read_6050_accel_bias(long *accel_bias); 112 | int mpu_set_accel_bias_6050_reg(const long *accel_bias); 113 | 114 | /* Data getter/setter APIs */ 115 | int mpu_get_gyro_reg(short *data, unsigned long *timestamp); 116 | int mpu_get_accel_reg(short *data, unsigned long *timestamp); 117 | int mpu_get_compass_reg(short *data, unsigned long *timestamp); 118 | int mpu_get_temperature(long *data, unsigned long *timestamp); 119 | 120 | int mpu_get_int_status(short *status); 121 | int mpu_read_fifo(short *gyro, short *accel, unsigned long *timestamp, 122 | unsigned char *sensors, unsigned char *more); 123 | int mpu_read_fifo_stream(unsigned short length, unsigned char *data, 124 | unsigned char *more); 125 | int mpu_reset_fifo(void); 126 | 127 | int mpu_write_mem(unsigned short mem_addr, unsigned short length, 128 | unsigned char *data); 129 | int mpu_read_mem(unsigned short mem_addr, unsigned short length, 130 | unsigned char *data); 131 | int mpu_load_firmware(unsigned short length, const unsigned char *firmware, 132 | unsigned short start_addr, unsigned short sample_rate); 133 | 134 | int mpu_reg_dump(void); 135 | int mpu_read_reg(unsigned char reg, unsigned char *data); 136 | int mpu_run_self_test(long *gyro, long *accel); 137 | int mpu_run_6500_self_test(long *gyro, long *accel, unsigned char debug); 138 | int mpu_register_tap_cb(void (*func)(unsigned char, unsigned char)); 139 | 140 | #endif /* #ifndef _INV_MPU_H_ */ 141 | 142 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/driver/eMPL/inv_mpu_dmp_motion_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /** 8 | * @addtogroup DRIVERS Sensor Driver Layer 9 | * @brief Hardware drivers to communicate with sensors via I2C. 10 | * 11 | * @{ 12 | * @file inv_mpu_dmp_motion_driver.h 13 | * @brief DMP image and interface functions. 14 | * @details All functions are preceded by the dmp_ prefix to 15 | * differentiate among MPL and general driver function calls. 16 | */ 17 | #ifndef _INV_MPU_DMP_MOTION_DRIVER_H_ 18 | #define _INV_MPU_DMP_MOTION_DRIVER_H_ 19 | 20 | #define TAP_X (0x01) 21 | #define TAP_Y (0x02) 22 | #define TAP_Z (0x04) 23 | #define TAP_XYZ (0x07) 24 | 25 | #define TAP_X_UP (0x01) 26 | #define TAP_X_DOWN (0x02) 27 | #define TAP_Y_UP (0x03) 28 | #define TAP_Y_DOWN (0x04) 29 | #define TAP_Z_UP (0x05) 30 | #define TAP_Z_DOWN (0x06) 31 | 32 | #define ANDROID_ORIENT_PORTRAIT (0x00) 33 | #define ANDROID_ORIENT_LANDSCAPE (0x01) 34 | #define ANDROID_ORIENT_REVERSE_PORTRAIT (0x02) 35 | #define ANDROID_ORIENT_REVERSE_LANDSCAPE (0x03) 36 | 37 | #define DMP_INT_GESTURE (0x01) 38 | #define DMP_INT_CONTINUOUS (0x02) 39 | 40 | #define DMP_FEATURE_TAP (0x001) 41 | #define DMP_FEATURE_ANDROID_ORIENT (0x002) 42 | #define DMP_FEATURE_LP_QUAT (0x004) 43 | #define DMP_FEATURE_PEDOMETER (0x008) 44 | #define DMP_FEATURE_6X_LP_QUAT (0x010) 45 | #define DMP_FEATURE_GYRO_CAL (0x020) 46 | #define DMP_FEATURE_SEND_RAW_ACCEL (0x040) 47 | #define DMP_FEATURE_SEND_RAW_GYRO (0x080) 48 | #define DMP_FEATURE_SEND_CAL_GYRO (0x100) 49 | 50 | #define INV_WXYZ_QUAT (0x100) 51 | 52 | /* Set up functions. */ 53 | int dmp_load_motion_driver_firmware(void); 54 | int dmp_set_fifo_rate(unsigned short rate); 55 | int dmp_get_fifo_rate(unsigned short *rate); 56 | int dmp_enable_feature(unsigned short mask); 57 | int dmp_get_enabled_features(unsigned short *mask); 58 | int dmp_set_interrupt_mode(unsigned char mode); 59 | int dmp_set_orientation(unsigned short orient); 60 | int dmp_set_gyro_bias(long *bias); 61 | int dmp_set_accel_bias(long *bias); 62 | 63 | /* Tap functions. */ 64 | int dmp_register_tap_cb(void (*func)(unsigned char, unsigned char)); 65 | int dmp_set_tap_thresh(unsigned char axis, unsigned short thresh); 66 | int dmp_set_tap_axes(unsigned char axis); 67 | int dmp_set_tap_count(unsigned char min_taps); 68 | int dmp_set_tap_time(unsigned short time); 69 | int dmp_set_tap_time_multi(unsigned short time); 70 | int dmp_set_shake_reject_thresh(long sf, unsigned short thresh); 71 | int dmp_set_shake_reject_time(unsigned short time); 72 | int dmp_set_shake_reject_timeout(unsigned short time); 73 | 74 | /* Android orientation functions. */ 75 | int dmp_register_android_orient_cb(void (*func)(unsigned char)); 76 | 77 | /* LP quaternion functions. */ 78 | int dmp_enable_lp_quat(unsigned char enable); 79 | int dmp_enable_6x_lp_quat(unsigned char enable); 80 | 81 | /* Pedometer functions. */ 82 | int dmp_get_pedometer_step_count(unsigned long *count); 83 | int dmp_set_pedometer_step_count(unsigned long count); 84 | int dmp_get_pedometer_walk_time(unsigned long *time); 85 | int dmp_set_pedometer_walk_time(unsigned long time); 86 | 87 | /* DMP gyro calibration functions. */ 88 | int dmp_enable_gyro_cal(unsigned char enable); 89 | 90 | /* Read function. This function should be called whenever the MPU interrupt is 91 | * detected. 92 | */ 93 | int dmp_read_fifo(short *gyro, short *accel, long *quat, 94 | unsigned long *timestamp, short *sensors, unsigned char *more); 95 | 96 | #endif /* #ifndef _INV_MPU_DMP_MOTION_DRIVER_H_ */ 97 | 98 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/driver/include/mlinclude.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | #ifndef INV_INCLUDE_H__ 7 | #define INV_INCLUDE_H__ 8 | 9 | #define INVENSENSE_FUNC_START 10 | 11 | #ifdef COVERAGE 12 | #include "utestCommon.h" 13 | #endif 14 | #ifdef PROFILE 15 | #include "profile.h" 16 | #endif 17 | 18 | #ifdef WIN32 19 | #ifdef COVERAGE 20 | 21 | extern int functionEnterLog(const char *file, const char *func); 22 | extern int functionExitLog(const char *file, const char *func); 23 | 24 | #undef INVENSENSE_FUNC_START 25 | #define INVENSENSE_FUNC_START __pragma(message(__FILE__ "|"__FUNCTION__ )) \ 26 | int dslkQjDsd = functionEnterLog(__FILE__, __FUNCTION__) 27 | #endif // COVERAGE 28 | #endif // WIN32 29 | 30 | #ifdef PROFILE 31 | #undef INVENSENSE_FUNC_START 32 | #define INVENSENSE_FUNC_START int dslkQjDsd = profileEnter(__FILE__, __FUNCTION__) 33 | #define return if ( profileExit(__FILE__, __FUNCTION__) ) return 34 | #endif // PROFILE 35 | 36 | // #define return if ( functionExitLog(__FILE__, __FUNCTION__) ) return 37 | 38 | #endif //INV_INCLUDE_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/driver/include/mlmath.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | /******************************************************************************* 7 | * 8 | * $Id: mlmath.h 5629 2011-06-11 03:13:08Z mcaramello $ 9 | * 10 | *******************************************************************************/ 11 | 12 | #ifndef _ML_MATH_H_ 13 | #define _ML_MATH_H_ 14 | 15 | #ifndef MLMATH 16 | // This define makes Microsoft pickup things like M_PI 17 | #define _USE_MATH_DEFINES 18 | #include 19 | 20 | #ifdef WIN32 21 | // Microsoft doesn't follow standards 22 | #define round(x)(((double)((long long)((x)>0?(x)+.5:(x)-.5)))) 23 | #define roundf(x)(((float )((long long)((x)>0?(x)+.5f:(x)-.5f)))) 24 | #endif 25 | 26 | #else // MLMATH 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | /* MPL needs below functions */ 32 | double ml_asin(double); 33 | double ml_atan(double); 34 | double ml_atan2(double, double); 35 | double ml_log(double); 36 | double ml_sqrt(double); 37 | double ml_ceil(double); 38 | double ml_floor(double); 39 | double ml_cos(double); 40 | double ml_sin(double); 41 | double ml_acos(double); 42 | #ifdef __cplusplus 43 | } // extern "C" 44 | #endif 45 | 46 | /* 47 | * We rename functions here to provide the hook for other 48 | * customized math functions. 49 | */ 50 | #define sqrt(x) ml_sqrt(x) 51 | #define log(x) ml_log(x) 52 | #define asin(x) ml_asin(x) 53 | #define atan(x) ml_atan(x) 54 | #define atan2(x,y) ml_atan2(x,y) 55 | #define ceil(x) ml_ceil(x) 56 | #define floor(x) ml_floor(x) 57 | #define fabs(x) (((x)<0)?-(x):(x)) 58 | #define round(x) (((double)((long long)((x)>0?(x)+.5:(x)-.5)))) 59 | #define roundf(x) (((float )((long long)((x)>0?(x)+.5f:(x)-.5f)))) 60 | #define cos(x) ml_cos(x) 61 | #define sin(x) ml_sin(x) 62 | #define acos(x) ml_acos(x) 63 | 64 | #define pow(x,y) ml_pow(x,y) 65 | 66 | #ifdef LINUX 67 | /* stubs for float version of math functions */ 68 | #define cosf(x) ml_cos(x) 69 | #define sinf(x) ml_sin(x) 70 | #define atan2f(x,y) ml_atan2(x,y) 71 | #define sqrtf(x) ml_sqrt(x) 72 | #endif 73 | 74 | 75 | 76 | #endif // MLMATH 77 | 78 | #ifndef M_PI 79 | #define M_PI 3.14159265358979 80 | #endif 81 | 82 | #ifndef ABS 83 | #define ABS(x) (((x)>=0)?(x):-(x)) 84 | #endif 85 | 86 | #ifndef MIN 87 | #define MIN(x,y) (((x)<(y))?(x):(y)) 88 | #endif 89 | 90 | #ifndef MAX 91 | #define MAX(x,y) (((x)>(y))?(x):(y)) 92 | #endif 93 | 94 | /*---------------------------*/ 95 | #endif /* !_ML_MATH_H_ */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/driver/include/mlos.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | 7 | #ifndef _MLOS_H 8 | #define _MLOS_H 9 | 10 | #ifndef __KERNEL__ 11 | #include 12 | #endif 13 | 14 | #include "mltypes.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #if defined(LINUX) || defined(__KERNEL__) 21 | typedef unsigned int HANDLE; 22 | #endif 23 | 24 | /* ------------ */ 25 | /* - Defines. - */ 26 | /* ------------ */ 27 | 28 | /* - MLOSCreateFile defines. - */ 29 | 30 | #define MLOS_GENERIC_READ ((unsigned int)0x80000000) 31 | #define MLOS_GENERIC_WRITE ((unsigned int)0x40000000) 32 | #define MLOS_FILE_SHARE_READ ((unsigned int)0x00000001) 33 | #define MLOS_FILE_SHARE_WRITE ((unsigned int)0x00000002) 34 | #define MLOS_OPEN_EXISTING ((unsigned int)0x00000003) 35 | 36 | /* ---------- */ 37 | /* - Enums. - */ 38 | /* ---------- */ 39 | 40 | /* --------------- */ 41 | /* - Structures. - */ 42 | /* --------------- */ 43 | 44 | /* --------------------- */ 45 | /* - Function p-types. - */ 46 | /* --------------------- */ 47 | 48 | #ifndef __KERNEL__ 49 | #include 50 | void *inv_malloc(unsigned int numBytes); 51 | inv_error_t inv_free(void *ptr); 52 | inv_error_t inv_create_mutex(HANDLE *mutex); 53 | inv_error_t inv_lock_mutex(HANDLE mutex); 54 | inv_error_t inv_unlock_mutex(HANDLE mutex); 55 | FILE *inv_fopen(char *filename); 56 | void inv_fclose(FILE *fp); 57 | 58 | inv_error_t inv_destroy_mutex(HANDLE handle); 59 | 60 | void inv_sleep(int mSecs); 61 | #ifdef EMPL 62 | inv_error_t inv_get_tick_count(inv_time_t *timestamp); 63 | #else 64 | inv_time_t inv_get_tick_count(void); 65 | #endif 66 | 67 | 68 | /* Kernel implmentations */ 69 | #define GFP_KERNEL (0x70) 70 | static inline void *kmalloc(size_t size, 71 | unsigned int gfp_flags) 72 | { 73 | (void)gfp_flags; 74 | return inv_malloc((unsigned int)size); 75 | } 76 | static inline void *kzalloc(size_t size, unsigned int gfp_flags) 77 | { 78 | void *tmp = inv_malloc((unsigned int)size); 79 | (void)gfp_flags; 80 | if (tmp) 81 | memset(tmp, 0, size); 82 | return tmp; 83 | } 84 | static inline void kfree(void *ptr) 85 | { 86 | inv_free(ptr); 87 | } 88 | static inline void msleep(long msecs) 89 | { 90 | inv_sleep(msecs); 91 | } 92 | static inline void udelay(unsigned long usecs) 93 | { 94 | inv_sleep((usecs + 999) / 1000); 95 | } 96 | #else 97 | #include 98 | #endif 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | #endif /* _MLOS_H */ 104 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/driver/include/stdint_invensense.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | #ifndef STDINT_INVENSENSE_H 7 | #define STDINT_INVENSENSE_H 8 | 9 | #ifndef WIN32 10 | 11 | #if defined __KERNEL__ 12 | #include 13 | #elif defined EMPL 14 | #include 15 | #include 16 | #else 17 | #include 18 | #endif 19 | 20 | #else 21 | 22 | #include 23 | 24 | typedef signed char int8_t; 25 | typedef short int16_t; 26 | typedef long int32_t; 27 | typedef long long int64_t; 28 | 29 | typedef unsigned char uint8_t; 30 | typedef unsigned short uint16_t; 31 | typedef unsigned long uint32_t; 32 | typedef unsigned long long uint64_t; 33 | 34 | typedef int int_fast8_t; 35 | typedef int int_fast16_t; 36 | typedef long int_fast32_t; 37 | 38 | typedef unsigned int uint_fast8_t; 39 | typedef unsigned int uint_fast16_t; 40 | typedef unsigned long uint_fast32_t; 41 | 42 | #endif 43 | 44 | #endif // STDINT_INVENSENSE_H -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/driver/nRF5/packet.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2010 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | /******************************************************************************* 7 | * $Id: $ 8 | *******************************************************************************/ 9 | 10 | /** 11 | * @defgroup STM32L STM32L System Layer 12 | * @brief STM32L System Layer APIs. 13 | * To interface with any platform, eMPL needs access to various 14 | * system layer functions. 15 | * 16 | * @{ 17 | * @file packet.h 18 | * @brief Defines needed for sending data/debug packets via USB. 19 | */ 20 | 21 | #ifndef __PACKET_H__ 22 | #define __PACKET_H__ 23 | 24 | #include "mltypes.h" 25 | 26 | typedef enum { 27 | PACKET_DATA_ACCEL = 0, 28 | PACKET_DATA_GYRO, 29 | PACKET_DATA_COMPASS, 30 | PACKET_DATA_QUAT, 31 | PACKET_DATA_EULER, 32 | PACKET_DATA_ROT, 33 | PACKET_DATA_HEADING, 34 | PACKET_DATA_LINEAR_ACCEL, 35 | NUM_DATA_PACKETS 36 | } eMPL_packet_e; 37 | 38 | /** 39 | * @brief Send a quaternion packet via UART. 40 | * The host is expected to use the data in this packet to graphically 41 | * represent the device orientation. To send quaternion in the same manner 42 | * as any other data packet, use eMPL_send_data. 43 | * @param[in] quat Quaternion data. 44 | */ 45 | void eMPL_send_quat(long *quat); 46 | 47 | /** 48 | * @brief Send a data packet via UART 49 | * @param[in] type Contents of packet (PACKET_DATA_ACCEL, etc). 50 | * @param[in] data Data (length dependent on contents). 51 | */ 52 | void eMPL_send_data(unsigned char type, long *data); 53 | 54 | #endif /* __PACKET_H__ */ 55 | 56 | /** 57 | * @} 58 | */ 59 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/eMPL-hal/eMPL_outputs.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /** 8 | * @defgroup HAL_Outputs 9 | * @brief Motion Library - HAL Outputs 10 | * Sets up common outputs for HAL 11 | * 12 | * @{ 13 | * @file eMPL_outputs.h 14 | * @brief Embedded MPL outputs. 15 | */ 16 | #ifndef _EMPL_OUTPUTS_H_ 17 | #define _EMPL_OUTPUTS_H_ 18 | 19 | #include "mltypes.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | int inv_get_sensor_type_accel(long *data, int8_t *accuracy, inv_time_t *timestamp); 26 | int inv_get_sensor_type_gyro(long *data, int8_t *accuracy, inv_time_t *timestamp); 27 | int inv_get_sensor_type_compass(long *data, int8_t *accuracy, inv_time_t *timestamp); 28 | int inv_get_sensor_type_quat(long *data, int8_t *accuracy, inv_time_t *timestamp); 29 | int inv_get_sensor_type_euler(long *data, int8_t *accuracy, inv_time_t *timestamp); 30 | int inv_get_sensor_type_rot_mat(long *data, int8_t *accuracy, inv_time_t *timestamp); 31 | int inv_get_sensor_type_heading(long *data, int8_t *accuracy, inv_time_t *timestamp); 32 | 33 | inv_error_t inv_enable_eMPL_outputs(void); 34 | inv_error_t inv_disable_eMPL_outputs(void); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* #ifndef _EMPL_OUTPUTS_H_ */ 41 | 42 | /** 43 | * @} 44 | */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/hal_outputs.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #include "mltypes.h" 8 | 9 | #ifndef INV_HAL_OUTPUTS_H__ 10 | #define INV_HAL_OUTPUTS_H__ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | int inv_get_sensor_type_orientation(float *values, int8_t *accuracy, 17 | inv_time_t * timestamp); 18 | int inv_get_sensor_type_accelerometer(float *values, int8_t *accuracy, 19 | inv_time_t * timestamp); 20 | int inv_get_sensor_type_gyroscope(float *values, int8_t *accuracy, 21 | inv_time_t * timestamp); 22 | int inv_get_sensor_type_gyroscope_raw(float *values, int8_t *accuracy, 23 | inv_time_t * timestamp); 24 | int inv_get_sensor_type_magnetic_field(float *values, int8_t *accuracy, 25 | inv_time_t * timestamp); 26 | int inv_get_sensor_type_rotation_vector(float *values, int8_t *accuracy, 27 | inv_time_t * timestamp); 28 | 29 | int inv_get_sensor_type_linear_acceleration(float *values, 30 | int8_t *accuracy, 31 | inv_time_t * timestamp); 32 | int inv_get_sensor_type_gravity(float *values, int8_t *accuracy, 33 | inv_time_t * timestamp); 34 | 35 | inv_error_t inv_enable_hal_outputs(void); 36 | inv_error_t inv_disable_hal_outputs(void); 37 | inv_error_t inv_init_hal_outputs(void); 38 | inv_error_t inv_start_hal_outputs(void); 39 | inv_error_t inv_stop_hal_outputs(void); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif // INV_HAL_OUTPUTS_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/invensense.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | 7 | /******************************************************************************* 8 | * 9 | * $Id:$ 10 | * 11 | ******************************************************************************/ 12 | 13 | /** 14 | * Main header file for Invensense's basic library. 15 | */ 16 | 17 | #include "data_builder.h" 18 | #include "hal_outputs.h" 19 | #include "message_layer.h" 20 | #include "mlmath.h" 21 | #include "ml_math_func.h" 22 | #include "mpl.h" 23 | #include "results_holder.h" 24 | #include "start_manager.h" 25 | #include "storage_manager.h" 26 | #include "log.h" 27 | #include "mlinclude.h" 28 | //#include "..\HAL\include\mlos.h" -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/message_layer.c: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /** 8 | * @defgroup Message_Layer message_layer 9 | * @brief Motion Library - Message Layer 10 | * Holds Low Occurance messages 11 | * 12 | * @{ 13 | * @file message_layer.c 14 | * @brief Holds Low Occurance Messages. 15 | */ 16 | #include "message_layer.h" 17 | #include "log.h" 18 | 19 | struct message_holder_t { 20 | long message; 21 | }; 22 | 23 | static struct message_holder_t mh; 24 | 25 | /** Sets a message. 26 | * @param[in] set The flags to set. 27 | * @param[in] clear Before setting anything this will clear these messages, 28 | * which is useful for mutually exclusive messages such 29 | * a motion or no motion message. 30 | * @param[in] level Level of the messages. It starts at 0, and may increase 31 | * in the future to allow more messages if the bit storage runs out. 32 | */ 33 | void inv_set_message(long set, long clear, int level) 34 | { 35 | if (level == 0) { 36 | mh.message &= ~clear; 37 | mh.message |= set; 38 | } 39 | } 40 | 41 | /** Returns Message Flags for Level 0 Messages. 42 | * Levels are to allow expansion of more messages in the future. 43 | * @param[in] clear If set, will clear the message. Typically this will be set 44 | * for one reader, so that you don't get the same message over and over. 45 | * @return bit field to corresponding message. 46 | */ 47 | long inv_get_message_level_0(int clear) 48 | { 49 | long msg; 50 | msg = mh.message; 51 | if (clear) { 52 | mh.message = 0; 53 | } 54 | return msg; 55 | } 56 | 57 | /** 58 | * @} 59 | */ 60 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/message_layer.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #ifndef INV_MESSAGE_LAYER_H__ 8 | #define INV_MESSAGE_LAYER_H__ 9 | 10 | #include "mltypes.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /* Level 0 Type Messages */ 17 | /** A motion event has occured */ 18 | #define INV_MSG_MOTION_EVENT (0x01) 19 | /** A no motion event has occured */ 20 | #define INV_MSG_NO_MOTION_EVENT (0x02) 21 | /** A setting of the gyro bias has occured */ 22 | #define INV_MSG_NEW_GB_EVENT (0x04) 23 | /** A setting of the compass bias has occured */ 24 | #define INV_MSG_NEW_CB_EVENT (0x08) 25 | /** A setting of the accel bias has occured */ 26 | #define INV_MSG_NEW_AB_EVENT (0x10) 27 | 28 | void inv_set_message(long set, long clear, int level); 29 | long inv_get_message_level_0(int clear); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // INV_MESSAGE_LAYER_H__ 36 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/ml_math_func.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #ifndef INVENSENSE_INV_MATH_FUNC_H__ 8 | #define INVENSENSE_INV_MATH_FUNC_H__ 9 | 10 | #include "mltypes.h" 11 | 12 | #define GYRO_MAG_SQR_SHIFT 6 13 | #define NUM_ROTATION_MATRIX_ELEMENTS (9) 14 | #define ROT_MATRIX_SCALE_LONG (1073741824L) 15 | #define ROT_MATRIX_SCALE_FLOAT (1073741824.0f) 16 | #define ROT_MATRIX_LONG_TO_FLOAT( longval ) \ 17 | ((float) ((longval) / ROT_MATRIX_SCALE_FLOAT )) 18 | #define SIGNM(k)((int)(k)&1?-1:1) 19 | #define SIGNSET(x) ((x) ? -1 : +1) 20 | 21 | #define INV_TWO_POWER_NEG_30 9.313225746154785e-010f 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef struct { 28 | float state[4]; 29 | float c[5]; 30 | float input; 31 | float output; 32 | } inv_biquad_filter_t; 33 | 34 | static inline float inv_q30_to_float(long q30) 35 | { 36 | return (float) q30 / ((float)(1L << 30)); 37 | } 38 | 39 | static inline double inv_q30_to_double(long q30) 40 | { 41 | return (double) q30 / ((double)(1L << 30)); 42 | } 43 | 44 | static inline float inv_q16_to_float(long q16) 45 | { 46 | return (float) q16 / (1L << 16); 47 | } 48 | 49 | static inline double inv_q16_to_double(long q16) 50 | { 51 | return (double) q16 / (1L << 16); 52 | } 53 | 54 | 55 | 56 | 57 | long inv_q29_mult(long a, long b); 58 | long inv_q30_mult(long a, long b); 59 | 60 | /* UMPL_ELIMINATE_64BIT Notes: 61 | * An alternate implementation using float instead of long long accudoublemulators 62 | * is provided for q29_mult and q30_mult. 63 | * When long long accumulators are used and an alternate implementation is not 64 | * available, we eliminate the entire function and header with a macro. 65 | */ 66 | #ifndef UMPL_ELIMINATE_64BIT 67 | long inv_q30_div(long a, long b); 68 | long inv_q_shift_mult(long a, long b, int shift); 69 | #endif 70 | 71 | void inv_q_mult(const long *q1, const long *q2, long *qProd); 72 | void inv_q_add(long *q1, long *q2, long *qSum); 73 | void inv_q_normalize(long *q); 74 | void inv_q_invert(const long *q, long *qInverted); 75 | void inv_q_multf(const float *q1, const float *q2, float *qProd); 76 | void inv_q_addf(const float *q1, const float *q2, float *qSum); 77 | void inv_q_normalizef(float *q); 78 | void inv_q_norm4(float *q); 79 | void inv_q_invertf(const float *q, float *qInverted); 80 | void inv_quaternion_to_rotation(const long *quat, long *rot); 81 | unsigned char *inv_int32_to_big8(long x, unsigned char *big8); 82 | long inv_big8_to_int32(const unsigned char *big8); 83 | short inv_big8_to_int16(const unsigned char *big8); 84 | short inv_little8_to_int16(const unsigned char *little8); 85 | unsigned char *inv_int16_to_big8(short x, unsigned char *big8); 86 | float inv_matrix_det(float *p, int *n); 87 | void inv_matrix_det_inc(float *a, float *b, int *n, int x, int y); 88 | double inv_matrix_detd(double *p, int *n); 89 | void inv_matrix_det_incd(double *a, double *b, int *n, int x, int y); 90 | float inv_wrap_angle(float ang); 91 | float inv_angle_diff(float ang1, float ang2); 92 | void inv_quaternion_to_rotation_vector(const long *quat, long *rot); 93 | unsigned short inv_orientation_matrix_to_scalar(const signed char *mtx); 94 | void inv_convert_to_body(unsigned short orientation, const long *input, long *output); 95 | void inv_convert_to_chip(unsigned short orientation, const long *input, long *output); 96 | void inv_convert_to_body_with_scale(unsigned short orientation, long sensitivity, const long *input, long *output); 97 | void inv_q_rotate(const long *q, const long *in, long *out); 98 | void inv_vector_normalize(long *vec, int length); 99 | uint32_t inv_checksum(const unsigned char *str, int len); 100 | float inv_compass_angle(const long *compass, const long *grav, 101 | const long *quat); 102 | unsigned long inv_get_gyro_sum_of_sqr(const long *gyro); 103 | 104 | #ifdef EMPL 105 | float inv_sinf(float x); 106 | float inv_cosf(float x); 107 | /* eMPL timestamps are assumed to be in milliseconds. */ 108 | static inline long inv_delta_time_ms(inv_time_t t1, inv_time_t t2) 109 | { 110 | return (long)((t1 - t2)); 111 | } 112 | #else 113 | static inline long inv_delta_time_ms(inv_time_t t1, inv_time_t t2) 114 | { 115 | return (long)((t1 - t2) / 1000000L); 116 | } 117 | #endif 118 | 119 | double quaternion_to_rotation_angle(const long *quat); 120 | double inv_vector_norm(const float *x); 121 | 122 | void inv_init_biquad_filter(inv_biquad_filter_t *pFilter, float *pBiquadCoeff); 123 | float inv_biquad_filter_process(inv_biquad_filter_t *pFilter, float input); 124 | void inv_calc_state_to_match_output(inv_biquad_filter_t *pFilter, float input); 125 | void inv_get_cross_product_vec(float *cgcross, float compass[3], float grav[3]); 126 | 127 | void mlMatrixVectorMult(long matrix[9], const long vecIn[3], long *vecOut); 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | #endif // INVENSENSE_INV_MATH_FUNC_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/mlmath.c: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /******************************************************************************* 8 | * 9 | * $Id: mlmath.c 5629 2011-06-11 03:13:08Z mcaramello $ 10 | * 11 | *******************************************************************************/ 12 | 13 | #include 14 | 15 | double ml_asin(double x) 16 | { 17 | return asin(x); 18 | } 19 | 20 | double ml_atan(double x) 21 | { 22 | return atan(x); 23 | } 24 | 25 | double ml_atan2(double x, double y) 26 | { 27 | return atan2(x, y); 28 | } 29 | 30 | double ml_log(double x) 31 | { 32 | return log(x); 33 | } 34 | 35 | double ml_sqrt(double x) 36 | { 37 | return sqrt(x); 38 | } 39 | 40 | double ml_ceil(double x) 41 | { 42 | return ceil(x); 43 | } 44 | 45 | double ml_floor(double x) 46 | { 47 | return floor(x); 48 | } 49 | 50 | double ml_cos(double x) 51 | { 52 | return cos(x); 53 | } 54 | 55 | double ml_sin(double x) 56 | { 57 | return sin(x); 58 | } 59 | 60 | double ml_acos(double x) 61 | { 62 | return acos(x); 63 | } 64 | 65 | double ml_pow(double x, double y) 66 | { 67 | return pow(x, y); 68 | } -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/mpl.c: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /** 8 | * @defgroup MPL mpl 9 | * @brief Motion Library - Start Point 10 | * Initializes MPL. 11 | * 12 | * @{ 13 | * @file mpl.c 14 | * @brief MPL start point. 15 | */ 16 | 17 | #include "storage_manager.h" 18 | #include "log.h" 19 | #include "mpl.h" 20 | #include "start_manager.h" 21 | #include "data_builder.h" 22 | #include "results_holder.h" 23 | #include "mlinclude.h" 24 | 25 | /** 26 | * @brief Initializes the MPL. Should be called first and once 27 | * @return Returns INV_SUCCESS if successful or an error code if not. 28 | */ 29 | inv_error_t inv_init_mpl(void) 30 | { 31 | inv_init_storage_manager(); 32 | 33 | /* initialize the start callback manager */ 34 | INV_ERROR_CHECK(inv_init_start_manager()); 35 | 36 | /* initialize the data builder */ 37 | INV_ERROR_CHECK(inv_init_data_builder()); 38 | 39 | INV_ERROR_CHECK(inv_enable_results_holder()); 40 | 41 | return INV_SUCCESS; 42 | } 43 | 44 | const char ml_ver[] = "InvenSense MA 5.1.2"; 45 | 46 | /** 47 | * @brief used to get the MPL version. 48 | * @param version a string where the MPL version gets stored. 49 | * @return INV_SUCCESS if successful or a non-zero error code otherwise. 50 | */ 51 | inv_error_t inv_get_version(char **version) 52 | { 53 | INVENSENSE_FUNC_START; 54 | /* cast out the const */ 55 | *version = (char *)&ml_ver; 56 | return INV_SUCCESS; 57 | } 58 | 59 | /** 60 | * @brief Starts the MPL. Typically called after inv_init_mpl() or after a 61 | * inv_stop_mpl() to start the MPL back up an running. 62 | * @return INV_SUCCESS if successful or a non-zero error code otherwise. 63 | */ 64 | inv_error_t inv_start_mpl(void) 65 | { 66 | INV_ERROR_CHECK(inv_execute_mpl_start_notification()); 67 | return INV_SUCCESS; 68 | } 69 | 70 | /** 71 | * @} 72 | */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/mpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #include "mltypes.h" 8 | 9 | #ifndef INV_MPL_H__ 10 | #define INV_MPL_H__ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | inv_error_t inv_init_mpl(void); 17 | inv_error_t inv_start_mpl(void); 18 | inv_error_t inv_get_version(char **version); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif // INV_MPL_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/results_holder.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #include "mltypes.h" 8 | 9 | #ifndef INV_RESULTS_HOLDER_H__ 10 | #define INV_RESULTS_HOLDER_H__ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #define INV_MOTION 0x0001 17 | #define INV_NO_MOTION 0x0002 18 | 19 | /**************************************************************************/ 20 | /* The value of inv_get_gyro_sum_of_sqr is scaled such the (1 dps)^2 = */ 21 | /* 2^GYRO_MAG_SQR_SHIFT. This number must be >=0 and even. */ 22 | /* The value of inv_accel_sum_of_sqr is scaled such that (1g)^2 = */ 23 | /* 2^ACC_MAG_SQR_SHIFT */ 24 | /**************************************************************************/ 25 | #define ACC_MAG_SQR_SHIFT 16 26 | 27 | void inv_store_gaming_quaternion(const long *quat, inv_time_t timestamp); 28 | 29 | // States 30 | #define SF_NORMAL 0 31 | #define SF_UNCALIBRATED 1 32 | #define SF_STARTUP_SETTLE 2 33 | #define SF_FAST_SETTLE 3 34 | #define SF_DISTURBANCE 4 35 | #define SF_SLOW_SETTLE 5 36 | 37 | int inv_get_acc_state(void); 38 | void inv_set_acc_state(int state); 39 | int inv_get_motion_state(unsigned int *cntr); 40 | void inv_set_motion_state(unsigned char state); 41 | inv_error_t inv_get_gravity(long *data); 42 | inv_error_t inv_get_6axis_quaternion(long *data); 43 | inv_error_t inv_get_quaternion(long *data); 44 | inv_error_t inv_get_quaternion_float(float *data); 45 | void inv_get_quaternion_set(long *data, int *accuracy, inv_time_t *timestamp); 46 | 47 | inv_error_t inv_enable_results_holder(void); 48 | inv_error_t inv_init_results_holder(void); 49 | 50 | /* Magnetic Field Parameters*/ 51 | void inv_set_local_field(const long *data); 52 | void inv_get_local_field(long *data); 53 | void inv_set_mag_scale(const long *data); 54 | void inv_get_mag_scale(long *data); 55 | void inv_set_compass_correction(const long *data, inv_time_t timestamp); 56 | void inv_get_compass_correction(long *data, inv_time_t *timestamp); 57 | int inv_got_compass_bias(void); 58 | void inv_set_compass_bias_found(int state); 59 | int inv_get_large_mag_field(void); 60 | void inv_set_large_mag_field(int state); 61 | void inv_set_compass_state(int state); 62 | int inv_get_compass_state(void); 63 | void inv_set_compass_bias_error(const long *bias_error); 64 | void inv_get_compass_bias_error(long *bias_error); 65 | inv_error_t inv_get_linear_accel(long *data); 66 | inv_error_t inv_get_accel(long *data); 67 | inv_error_t inv_get_accel_float(float *data); 68 | inv_error_t inv_get_gyro_float(float *data); 69 | inv_error_t inv_get_linear_accel_float(float *data); 70 | void inv_set_heading_confidence_interval(float ci); 71 | float inv_get_heading_confidence_interval(void); 72 | 73 | int inv_got_accel_bias(void); 74 | void inv_set_accel_bias_found(int state); 75 | 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif // INV_RESULTS_HOLDER_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/start_manager.c: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /******************************************************************************* 9 | * 10 | * $Id:$ 11 | * 12 | ******************************************************************************/ 13 | /** 14 | * @defgroup Start_Manager start_manager 15 | * @brief Motion Library - Start Manager 16 | * Start Manager 17 | * 18 | * @{ 19 | * @file start_manager.c 20 | * @brief This handles all the callbacks when inv_start_mpl() is called. 21 | */ 22 | 23 | 24 | #include 25 | #include "log.h" 26 | #include "start_manager.h" 27 | 28 | typedef inv_error_t (*inv_start_cb_func)(); 29 | struct inv_start_cb_t { 30 | int num_cb; 31 | inv_start_cb_func start_cb[INV_MAX_START_CB]; 32 | }; 33 | 34 | static struct inv_start_cb_t inv_start_cb; 35 | 36 | /** Initilize the start manager. Typically called by inv_start_mpl(); 37 | * @return Returns INV_SUCCESS if successful or an error code if not. 38 | */ 39 | inv_error_t inv_init_start_manager(void) 40 | { 41 | memset(&inv_start_cb, 0, sizeof(inv_start_cb)); 42 | return INV_SUCCESS; 43 | } 44 | 45 | /** Removes a callback from start notification 46 | * @param[in] start_cb function to remove from start notification 47 | * @return Returns INV_SUCCESS if successful or an error code if not. 48 | */ 49 | inv_error_t inv_unregister_mpl_start_notification(inv_error_t (*start_cb)(void)) 50 | { 51 | int kk; 52 | 53 | for (kk=0; kk= INV_MAX_START_CB) 76 | return INV_ERROR_INVALID_PARAMETER; 77 | 78 | inv_start_cb.start_cb[inv_start_cb.num_cb] = start_cb; 79 | inv_start_cb.num_cb++; 80 | return INV_SUCCESS; 81 | } 82 | 83 | /** Callback all the functions that want to be notified when inv_start_mpl() was 84 | * called. 85 | * @return Returns INV_SUCCESS if successful or an error code if not. 86 | */ 87 | inv_error_t inv_execute_mpl_start_notification(void) 88 | { 89 | inv_error_t result,first_error; 90 | int kk; 91 | 92 | first_error = INV_SUCCESS; 93 | 94 | for (kk = 0; kk < inv_start_cb.num_cb; ++kk) { 95 | result = inv_start_cb.start_cb[kk](); 96 | if (result && (first_error == INV_SUCCESS)) { 97 | first_error = result; 98 | } 99 | } 100 | return first_error; 101 | } 102 | 103 | /** 104 | * @} 105 | */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/start_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #ifndef INV_START_MANAGER_H__ 8 | #define INV_START_MANAGER_H__ 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #include "mltypes.h" 15 | 16 | /** Max number of start callbacks we can handle. */ 17 | #define INV_MAX_START_CB 20 18 | 19 | inv_error_t inv_init_start_manager(void); 20 | inv_error_t inv_register_mpl_start_notification(inv_error_t (*start_cb)(void)); 21 | inv_error_t inv_execute_mpl_start_notification(void); 22 | inv_error_t inv_unregister_mpl_start_notification(inv_error_t (*start_cb)(void)); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | #endif // INV_START_MANAGER_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mllite/storage_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #include "mltypes.h" 8 | 9 | #ifndef INV_STORAGE_MANAGER_H__ 10 | #define INV_STORAGE_MANAGER_H__ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | inv_error_t inv_register_load_store( 17 | inv_error_t (*load_func)(const unsigned char *data), 18 | inv_error_t (*save_func)(unsigned char *data), 19 | size_t size, unsigned int key); 20 | void inv_init_storage_manager(void); 21 | 22 | inv_error_t inv_get_mpl_state_size(size_t *size); 23 | inv_error_t inv_load_mpl_states(const unsigned char *data, size_t len); 24 | inv_error_t inv_save_mpl_states(unsigned char *data, size_t len); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif /* INV_STORAGE_MANAGER_H__ */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/accel_auto_cal.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /******************************************************************************* 9 | * 10 | * $Id$ 11 | * 12 | ******************************************************************************/ 13 | 14 | #ifndef MLDMP_ACCEL_AUTO_CALIBRATION_H__ 15 | #define MLDMP_ACCEL_AUTO_CALIBRATION_H__ 16 | 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | inv_error_t inv_enable_in_use_auto_calibration(void); 24 | inv_error_t inv_disable_in_use_auto_calibration(void); 25 | inv_error_t inv_stop_in_use_auto_calibration(void); 26 | inv_error_t inv_start_in_use_auto_calibration(void); 27 | inv_error_t inv_in_use_auto_calibration_is_enabled(unsigned char *is_enabled); 28 | inv_error_t inv_init_in_use_auto_calibration(void); 29 | void inv_init_accel_maxmin(void); 30 | void inv_record_good_accel_maxmin(void); 31 | int inv_get_accel_bias_stage(void); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // MLDMP_ACCEL_AUTO_CALIBRATION_H__ 38 | 39 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/compass_vec_cal.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /******************************************************************************* 9 | * 10 | * $Id:$ 11 | * 12 | ******************************************************************************/ 13 | 14 | #ifndef COMPASS_ONLY_CAL_H__ 15 | #define COMPASS_ONLY_CAL_H__ 16 | 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | inv_error_t inv_enable_vector_compass_cal(void); 24 | inv_error_t inv_disable_vector_compass_cal(void); 25 | inv_error_t inv_start_vector_compass_cal(void); 26 | inv_error_t inv_stop_vector_compass_cal(void); 27 | void inv_vector_compass_cal_sensitivity(float sens); 28 | inv_error_t inv_init_vector_compass_cal(void); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // COMPASS_ONLY_CAL_H__ 35 | 36 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/fast_no_motion.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /****************************************************************************** 9 | * 10 | * $Id$ 11 | * 12 | *****************************************************************************/ 13 | 14 | #ifndef MLDMP_FAST_NO_MOTION_H__ 15 | #define MLDMP_FAST_NO_MOTION_H__ 16 | 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | inv_error_t inv_enable_fast_nomot(void); 24 | inv_error_t inv_disable_fast_nomot(void); 25 | inv_error_t inv_start_fast_nomot(void); 26 | inv_error_t inv_stop_fast_nomot(void); 27 | inv_error_t inv_init_fast_nomot(void); 28 | void inv_set_default_number_of_samples(int count); 29 | inv_error_t inv_fast_nomot_is_enabled(unsigned char *is_enabled); 30 | inv_error_t inv_update_fast_nomot(long *gyro); 31 | 32 | void inv_get_fast_nomot_accel_param(long *cntr, long long *param); 33 | void inv_get_fast_nomot_compass_param(long *cntr, long long *param); 34 | void inv_set_fast_nomot_accel_threshold(long long thresh); 35 | void inv_set_fast_nomot_compass_threshold(long long thresh); 36 | void int_set_fast_nomot_gyro_threshold(long long thresh); 37 | 38 | void inv_fnm_debug_print(void); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | 45 | #endif // MLDMP_FAST_NO_MOTION_H__ 46 | 47 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/fusion_9axis.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /****************************************************************************** 9 | * 10 | * $Id$ 11 | * 12 | *****************************************************************************/ 13 | 14 | #ifndef MLDMP_FUSION9AXIS_H__ 15 | #define MLDMP_FUSION9AXIS_H__ 16 | 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | void inv_init_9x_fusion(void); 24 | inv_error_t inv_9x_fusion_state_change(unsigned char newState); 25 | inv_error_t inv_enable_9x_sensor_fusion(void); 26 | inv_error_t inv_disable_9x_sensor_fusion(void); 27 | inv_error_t inv_start_9x_sensor_fusion(void); 28 | inv_error_t inv_stop_9x_sensor_fusion(void); 29 | inv_error_t inv_9x_fusion_set_mag_fb(float fb); 30 | inv_error_t inv_9x_fusion_enable_jitter_reduction(int en); 31 | inv_error_t inv_9x_fusion_use_timestamps(int en); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | 38 | #endif // MLDMP_FUSION9AXIS_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/gyro_tc.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /****************************************************************************** 9 | * 10 | * $Id$ 11 | * 12 | *****************************************************************************/ 13 | 14 | #ifndef _GYRO_TC_H 15 | #define _GYRO_TC_H_ 16 | 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | inv_error_t inv_enable_gyro_tc(void); 24 | inv_error_t inv_disable_gyro_tc(void); 25 | inv_error_t inv_start_gyro_tc(void); 26 | inv_error_t inv_stop_gyro_tc(void); 27 | 28 | inv_error_t inv_get_gyro_ts(long *data); 29 | inv_error_t inv_set_gyro_ts(long *data); 30 | 31 | inv_error_t inv_init_gyro_ts(void); 32 | 33 | inv_error_t inv_set_gtc_max_temp(long data); 34 | inv_error_t inv_set_gtc_min_temp(long data); 35 | 36 | inv_error_t inv_print_gtc_data(void); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* _GYRO_TC_H */ 43 | 44 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/heading_from_gyro.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /****************************************************************************** 9 | * 10 | * $Id$ 11 | * 12 | *****************************************************************************/ 13 | 14 | #ifndef _HEADING_FROM_GYRO_H_ 15 | #define _HEADING_FROM_GYRO_H_ 16 | #include "mltypes.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | inv_error_t inv_enable_heading_from_gyro(void); 23 | inv_error_t inv_disable_heading_from_gyro(void); 24 | void inv_init_heading_from_gyro(void); 25 | inv_error_t inv_start_heading_from_gyro(void); 26 | inv_error_t inv_stop_heading_from_gyro(void); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | 33 | #endif /* _HEADING_FROM_GYRO_H_ */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/inv_math.h: -------------------------------------------------------------------------------- 1 | /* math.h has many functions and defines that are not consistent across 2 | * platforms. This address that */ 3 | 4 | #ifdef _WINDOWS 5 | #define _USE_MATH_DEFINES 6 | #endif 7 | 8 | #include -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/invensense_adv.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2012 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | 7 | /******************************************************************************* 8 | * 9 | * $Id:$ 10 | * 11 | ******************************************************************************/ 12 | 13 | /* 14 | Main header file for Invensense's Advanced library. 15 | */ 16 | 17 | #include "accel_auto_cal.h" 18 | #include "compass_vec_cal.h" 19 | #include "fast_no_motion.h" 20 | #include "fusion_9axis.h" 21 | #include "gyro_tc.h" 22 | #include "heading_from_gyro.h" 23 | #include "mag_disturb.h" 24 | #include "motion_no_motion.h" 25 | #include "no_gyro_fusion.h" 26 | #include "quaternion_supervisor.h" 27 | #include "mag_disturb.h" -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/mag_disturb.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | #ifndef MLDMP_MAGDISTURB_H__ 9 | #define MLDMP_MAGDISTURB_H__ 10 | 11 | #include "mltypes.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | int inv_check_magnetic_disturbance(unsigned long delta_time, const long *quat, 18 | const long *compass, const long *gravity); 19 | 20 | void inv_track_dip_angle(int mode, float currdip); 21 | 22 | inv_error_t inv_enable_magnetic_disturbance(void); 23 | inv_error_t inv_disable_magnetic_disturbance(void); 24 | int inv_get_magnetic_disturbance_state(void); 25 | inv_error_t inv_set_magnetic_disturbance(int time_ms); 26 | inv_error_t inv_disable_dip_tracking(void); 27 | inv_error_t inv_enable_dip_tracking(void); 28 | inv_error_t inv_init_magnetic_disturbance(void); 29 | 30 | float Mag3ofNormalizedLong(const long *x); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | 37 | #endif // MLDMP_MAGDISTURB_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/motion_no_motion.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #ifndef INV_MOTION_NO_MOTION_H__ 8 | #define INV_MOTION_NO_MOTION_H__ 9 | 10 | #include "mltypes.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | inv_error_t inv_enable_motion_no_motion(void); 17 | inv_error_t inv_disable_motion_no_motion(void); 18 | inv_error_t inv_init_motion_no_motion(void); 19 | inv_error_t inv_start_motion_no_motion(void); 20 | inv_error_t inv_stop_motion_no_motion(void); 21 | 22 | inv_error_t inv_set_no_motion_time(long time_ms); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif // INV_MOTION_NO_MOTION_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/no_gyro_fusion.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | 9 | /****************************************************************************** 10 | * 11 | * $Id$ 12 | * 13 | *****************************************************************************/ 14 | 15 | #ifndef MLDMP_NOGYROFUSION_H__ 16 | #define MLDMP_NOGYROFUSION_H__ 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | inv_error_t inv_enable_no_gyro_fusion(void); 24 | inv_error_t inv_disable_no_gyro_fusion(void); 25 | inv_error_t inv_start_no_gyro_fusion(void); 26 | inv_error_t inv_start_no_gyro_fusion(void); 27 | inv_error_t inv_init_no_gyro_fusion(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | 34 | #endif // MLDMP_NOGYROFUSION_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core/mpl/quaternion_supervisor.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #ifndef INV_QUATERNION_SUPERVISOR_H__ 8 | #define INV_QUATERNION_SUPERVISOR_H__ 9 | 10 | #include "mltypes.h" 11 | 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | inv_error_t inv_enable_quaternion(void); 18 | inv_error_t inv_disable_quaternion(void); 19 | inv_error_t inv_init_quaternion(void); 20 | inv_error_t inv_start_quaternion(void); 21 | void inv_set_quaternion(long *quat); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif // INV_QUATERNION_SUPERVISOR_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/driver/eMPL/inv_mpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /** 8 | * @addtogroup DRIVERS Sensor Driver Layer 9 | * @brief Hardware drivers to communicate with sensors via I2C. 10 | * 11 | * @{ 12 | * @file inv_mpu.h 13 | * @brief An I2C-based driver for Invensense gyroscopes. 14 | * @details This driver currently works for the following devices: 15 | * MPU6050 16 | * MPU6500 17 | * MPU9150 (or MPU6050 w/ AK8975 on the auxiliary bus) 18 | * MPU9250 (or MPU6500 w/ AK8963 on the auxiliary bus) 19 | */ 20 | 21 | #ifndef _INV_MPU_H_ 22 | #define _INV_MPU_H_ 23 | 24 | #define INV_X_GYRO (0x40) 25 | #define INV_Y_GYRO (0x20) 26 | #define INV_Z_GYRO (0x10) 27 | #define INV_XYZ_GYRO (INV_X_GYRO | INV_Y_GYRO | INV_Z_GYRO) 28 | #define INV_XYZ_ACCEL (0x08) 29 | #define INV_XYZ_COMPASS (0x01) 30 | 31 | struct int_param_s { 32 | #if defined EMPL_TARGET_MSP430 || defined MOTION_DRIVER_TARGET_MSP430 33 | void (*cb)(void); 34 | unsigned short pin; 35 | unsigned char lp_exit; 36 | unsigned char active_low; 37 | #elif defined EMPL_TARGET_UC3L0 38 | unsigned long pin; 39 | void (*cb)(volatile void*); 40 | void *arg; 41 | #elif defined EMPL_TARGET_STM32F4 42 | void (*cb)(void); 43 | #endif 44 | }; 45 | 46 | #define MPU_INT_STATUS_DATA_READY (0x0001) 47 | #define MPU_INT_STATUS_DMP (0x0002) 48 | #define MPU_INT_STATUS_PLL_READY (0x0004) 49 | #define MPU_INT_STATUS_I2C_MST (0x0008) 50 | #define MPU_INT_STATUS_FIFO_OVERFLOW (0x0010) 51 | #define MPU_INT_STATUS_ZMOT (0x0020) 52 | #define MPU_INT_STATUS_MOT (0x0040) 53 | #define MPU_INT_STATUS_FREE_FALL (0x0080) 54 | #define MPU_INT_STATUS_DMP_0 (0x0100) 55 | #define MPU_INT_STATUS_DMP_1 (0x0200) 56 | #define MPU_INT_STATUS_DMP_2 (0x0400) 57 | #define MPU_INT_STATUS_DMP_3 (0x0800) 58 | #define MPU_INT_STATUS_DMP_4 (0x1000) 59 | #define MPU_INT_STATUS_DMP_5 (0x2000) 60 | 61 | /* Set up APIs */ 62 | int mpu_init(struct int_param_s *int_param); 63 | int mpu_init_slave(void); 64 | int mpu_set_bypass(unsigned char bypass_on); 65 | 66 | /* Configuration APIs */ 67 | int mpu_lp_accel_mode(unsigned short rate); 68 | int mpu_lp_motion_interrupt(unsigned short thresh, unsigned char time, 69 | unsigned short lpa_freq); 70 | int mpu_set_int_level(unsigned char active_low); 71 | int mpu_set_int_latched(unsigned char enable); 72 | 73 | int mpu_set_dmp_state(unsigned char enable); 74 | int mpu_get_dmp_state(unsigned char *enabled); 75 | 76 | int mpu_get_lpf(unsigned short *lpf); 77 | int mpu_set_lpf(unsigned short lpf); 78 | 79 | int mpu_get_gyro_fsr(unsigned short *fsr); 80 | int mpu_set_gyro_fsr(unsigned short fsr); 81 | 82 | int mpu_get_accel_fsr(unsigned char *fsr); 83 | int mpu_set_accel_fsr(unsigned char fsr); 84 | 85 | int mpu_get_compass_fsr(unsigned short *fsr); 86 | 87 | int mpu_get_gyro_sens(float *sens); 88 | int mpu_get_accel_sens(unsigned short *sens); 89 | 90 | int mpu_get_sample_rate(unsigned short *rate); 91 | int mpu_set_sample_rate(unsigned short rate); 92 | int mpu_get_compass_sample_rate(unsigned short *rate); 93 | int mpu_set_compass_sample_rate(unsigned short rate); 94 | 95 | int mpu_get_fifo_config(unsigned char *sensors); 96 | int mpu_configure_fifo(unsigned char sensors); 97 | 98 | int mpu_get_power_state(unsigned char *power_on); 99 | int mpu_set_sensors(unsigned char sensors); 100 | 101 | int mpu_read_6500_accel_bias(long *accel_bias); 102 | int mpu_set_gyro_bias_reg(long * gyro_bias); 103 | int mpu_set_accel_bias_6500_reg(const long *accel_bias); 104 | int mpu_read_6050_accel_bias(long *accel_bias); 105 | int mpu_set_accel_bias_6050_reg(const long *accel_bias); 106 | 107 | /* Data getter/setter APIs */ 108 | int mpu_get_gyro_reg(short *data, unsigned long *timestamp); 109 | int mpu_get_accel_reg(short *data, unsigned long *timestamp); 110 | int mpu_get_compass_reg(short *data, unsigned long *timestamp); 111 | int mpu_get_temperature(long *data, unsigned long *timestamp); 112 | 113 | int mpu_get_int_status(short *status); 114 | int mpu_read_fifo(short *gyro, short *accel, unsigned long *timestamp, 115 | unsigned char *sensors, unsigned char *more); 116 | int mpu_read_fifo_stream(unsigned short length, unsigned char *data, 117 | unsigned char *more); 118 | int mpu_reset_fifo(void); 119 | 120 | int mpu_write_mem(unsigned short mem_addr, unsigned short length, 121 | unsigned char *data); 122 | int mpu_read_mem(unsigned short mem_addr, unsigned short length, 123 | unsigned char *data); 124 | int mpu_load_firmware(unsigned short length, const unsigned char *firmware, 125 | unsigned short start_addr, unsigned short sample_rate); 126 | 127 | int mpu_reg_dump(void); 128 | int mpu_read_reg(unsigned char reg, unsigned char *data); 129 | int mpu_run_self_test(long *gyro, long *accel); 130 | int mpu_run_6500_self_test(long *gyro, long *accel, unsigned char debug); 131 | int mpu_register_tap_cb(void (*func)(unsigned char, unsigned char)); 132 | 133 | #endif /* #ifndef _INV_MPU_H_ */ 134 | 135 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/driver/eMPL/inv_mpu_dmp_motion_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /** 8 | * @addtogroup DRIVERS Sensor Driver Layer 9 | * @brief Hardware drivers to communicate with sensors via I2C. 10 | * 11 | * @{ 12 | * @file inv_mpu_dmp_motion_driver.h 13 | * @brief DMP image and interface functions. 14 | * @details All functions are preceded by the dmp_ prefix to 15 | * differentiate among MPL and general driver function calls. 16 | */ 17 | #ifndef _INV_MPU_DMP_MOTION_DRIVER_H_ 18 | #define _INV_MPU_DMP_MOTION_DRIVER_H_ 19 | 20 | #define TAP_X (0x01) 21 | #define TAP_Y (0x02) 22 | #define TAP_Z (0x04) 23 | #define TAP_XYZ (0x07) 24 | 25 | #define TAP_X_UP (0x01) 26 | #define TAP_X_DOWN (0x02) 27 | #define TAP_Y_UP (0x03) 28 | #define TAP_Y_DOWN (0x04) 29 | #define TAP_Z_UP (0x05) 30 | #define TAP_Z_DOWN (0x06) 31 | 32 | #define ANDROID_ORIENT_PORTRAIT (0x00) 33 | #define ANDROID_ORIENT_LANDSCAPE (0x01) 34 | #define ANDROID_ORIENT_REVERSE_PORTRAIT (0x02) 35 | #define ANDROID_ORIENT_REVERSE_LANDSCAPE (0x03) 36 | 37 | #define DMP_INT_GESTURE (0x01) 38 | #define DMP_INT_CONTINUOUS (0x02) 39 | 40 | #define DMP_FEATURE_TAP (0x001) 41 | #define DMP_FEATURE_ANDROID_ORIENT (0x002) 42 | #define DMP_FEATURE_LP_QUAT (0x004) 43 | #define DMP_FEATURE_PEDOMETER (0x008) 44 | #define DMP_FEATURE_6X_LP_QUAT (0x010) 45 | #define DMP_FEATURE_GYRO_CAL (0x020) 46 | #define DMP_FEATURE_SEND_RAW_ACCEL (0x040) 47 | #define DMP_FEATURE_SEND_RAW_GYRO (0x080) 48 | #define DMP_FEATURE_SEND_CAL_GYRO (0x100) 49 | 50 | #define INV_WXYZ_QUAT (0x100) 51 | 52 | /* Set up functions. */ 53 | int dmp_load_motion_driver_firmware(void); 54 | int dmp_set_fifo_rate(unsigned short rate); 55 | int dmp_get_fifo_rate(unsigned short *rate); 56 | int dmp_enable_feature(unsigned short mask); 57 | int dmp_get_enabled_features(unsigned short *mask); 58 | int dmp_set_interrupt_mode(unsigned char mode); 59 | int dmp_set_orientation(unsigned short orient); 60 | int dmp_set_gyro_bias(long *bias); 61 | int dmp_set_accel_bias(long *bias); 62 | 63 | /* Tap functions. */ 64 | int dmp_register_tap_cb(void (*func)(unsigned char, unsigned char)); 65 | int dmp_set_tap_thresh(unsigned char axis, unsigned short thresh); 66 | int dmp_set_tap_axes(unsigned char axis); 67 | int dmp_set_tap_count(unsigned char min_taps); 68 | int dmp_set_tap_time(unsigned short time); 69 | int dmp_set_tap_time_multi(unsigned short time); 70 | int dmp_set_shake_reject_thresh(long sf, unsigned short thresh); 71 | int dmp_set_shake_reject_time(unsigned short time); 72 | int dmp_set_shake_reject_timeout(unsigned short time); 73 | 74 | /* Android orientation functions. */ 75 | int dmp_register_android_orient_cb(void (*func)(unsigned char)); 76 | 77 | /* LP quaternion functions. */ 78 | int dmp_enable_lp_quat(unsigned char enable); 79 | int dmp_enable_6x_lp_quat(unsigned char enable); 80 | 81 | /* Pedometer functions. */ 82 | int dmp_get_pedometer_step_count(unsigned long *count); 83 | int dmp_set_pedometer_step_count(unsigned long count); 84 | int dmp_get_pedometer_walk_time(unsigned long *time); 85 | int dmp_set_pedometer_walk_time(unsigned long time); 86 | 87 | /* DMP gyro calibration functions. */ 88 | int dmp_enable_gyro_cal(unsigned char enable); 89 | 90 | /* Read function. This function should be called whenever the MPU interrupt is 91 | * detected. 92 | */ 93 | int dmp_read_fifo(short *gyro, short *accel, long *quat, 94 | unsigned long *timestamp, short *sensors, unsigned char *more); 95 | 96 | #endif /* #ifndef _INV_MPU_DMP_MOTION_DRIVER_H_ */ 97 | 98 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/driver/include/mlinclude.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | #ifndef INV_INCLUDE_H__ 7 | #define INV_INCLUDE_H__ 8 | 9 | #define INVENSENSE_FUNC_START typedef int invensensePutFunctionCallsHere 10 | 11 | #ifdef COVERAGE 12 | #include "utestCommon.h" 13 | #endif 14 | #ifdef PROFILE 15 | #include "profile.h" 16 | #endif 17 | 18 | #ifdef WIN32 19 | #ifdef COVERAGE 20 | 21 | extern int functionEnterLog(const char *file, const char *func); 22 | extern int functionExitLog(const char *file, const char *func); 23 | 24 | #undef INVENSENSE_FUNC_START 25 | #define INVENSENSE_FUNC_START __pragma(message(__FILE__ "|"__FUNCTION__ )) \ 26 | int dslkQjDsd = functionEnterLog(__FILE__, __FUNCTION__) 27 | #endif // COVERAGE 28 | #endif // WIN32 29 | 30 | #ifdef PROFILE 31 | #undef INVENSENSE_FUNC_START 32 | #define INVENSENSE_FUNC_START int dslkQjDsd = profileEnter(__FILE__, __FUNCTION__) 33 | #define return if ( profileExit(__FILE__, __FUNCTION__) ) return 34 | #endif // PROFILE 35 | 36 | // #define return if ( functionExitLog(__FILE__, __FUNCTION__) ) return 37 | 38 | #endif //INV_INCLUDE_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/driver/include/mlmath.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | /******************************************************************************* 7 | * 8 | * $Id: mlmath.h 5629 2011-06-11 03:13:08Z mcaramello $ 9 | * 10 | *******************************************************************************/ 11 | 12 | #ifndef _ML_MATH_H_ 13 | #define _ML_MATH_H_ 14 | 15 | #ifndef MLMATH 16 | // This define makes Microsoft pickup things like M_PI 17 | #define _USE_MATH_DEFINES 18 | #include 19 | 20 | #ifdef WIN32 21 | // Microsoft doesn't follow standards 22 | #define round(x)(((double)((long long)((x)>0?(x)+.5:(x)-.5)))) 23 | #define roundf(x)(((float )((long long)((x)>0?(x)+.5f:(x)-.5f)))) 24 | #endif 25 | 26 | #else // MLMATH 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | /* MPL needs below functions */ 32 | double ml_asin(double); 33 | double ml_atan(double); 34 | double ml_atan2(double, double); 35 | double ml_log(double); 36 | double ml_sqrt(double); 37 | double ml_ceil(double); 38 | double ml_floor(double); 39 | double ml_cos(double); 40 | double ml_sin(double); 41 | double ml_acos(double); 42 | #ifdef __cplusplus 43 | } // extern "C" 44 | #endif 45 | 46 | /* 47 | * We rename functions here to provide the hook for other 48 | * customized math functions. 49 | */ 50 | #define sqrt(x) ml_sqrt(x) 51 | #define log(x) ml_log(x) 52 | #define asin(x) ml_asin(x) 53 | #define atan(x) ml_atan(x) 54 | #define atan2(x,y) ml_atan2(x,y) 55 | #define ceil(x) ml_ceil(x) 56 | #define floor(x) ml_floor(x) 57 | #define fabs(x) (((x)<0)?-(x):(x)) 58 | #define round(x) (((double)((long long)((x)>0?(x)+.5:(x)-.5)))) 59 | #define roundf(x) (((float )((long long)((x)>0?(x)+.5f:(x)-.5f)))) 60 | #define cos(x) ml_cos(x) 61 | #define sin(x) ml_sin(x) 62 | #define acos(x) ml_acos(x) 63 | 64 | #define pow(x,y) ml_pow(x,y) 65 | 66 | #ifdef LINUX 67 | /* stubs for float version of math functions */ 68 | #define cosf(x) ml_cos(x) 69 | #define sinf(x) ml_sin(x) 70 | #define atan2f(x,y) ml_atan2(x,y) 71 | #define sqrtf(x) ml_sqrt(x) 72 | #endif 73 | 74 | 75 | 76 | #endif // MLMATH 77 | 78 | #ifndef M_PI 79 | #define M_PI 3.14159265358979 80 | #endif 81 | 82 | #ifndef ABS 83 | #define ABS(x) (((x)>=0)?(x):-(x)) 84 | #endif 85 | 86 | #ifndef MIN 87 | #define MIN(x,y) (((x)<(y))?(x):(y)) 88 | #endif 89 | 90 | #ifndef MAX 91 | #define MAX(x,y) (((x)>(y))?(x):(y)) 92 | #endif 93 | 94 | /*---------------------------*/ 95 | #endif /* !_ML_MATH_H_ */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/driver/include/mlos.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | 7 | #ifndef _MLOS_H 8 | #define _MLOS_H 9 | 10 | #ifndef __KERNEL__ 11 | #include 12 | #endif 13 | 14 | #include "mltypes.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #if defined(LINUX) || defined(__KERNEL__) 21 | typedef unsigned int HANDLE; 22 | #endif 23 | 24 | /* ------------ */ 25 | /* - Defines. - */ 26 | /* ------------ */ 27 | 28 | /* - MLOSCreateFile defines. - */ 29 | 30 | #define MLOS_GENERIC_READ ((unsigned int)0x80000000) 31 | #define MLOS_GENERIC_WRITE ((unsigned int)0x40000000) 32 | #define MLOS_FILE_SHARE_READ ((unsigned int)0x00000001) 33 | #define MLOS_FILE_SHARE_WRITE ((unsigned int)0x00000002) 34 | #define MLOS_OPEN_EXISTING ((unsigned int)0x00000003) 35 | 36 | /* ---------- */ 37 | /* - Enums. - */ 38 | /* ---------- */ 39 | 40 | /* --------------- */ 41 | /* - Structures. - */ 42 | /* --------------- */ 43 | 44 | /* --------------------- */ 45 | /* - Function p-types. - */ 46 | /* --------------------- */ 47 | 48 | #ifndef __KERNEL__ 49 | #include 50 | void *inv_malloc(unsigned int numBytes); 51 | inv_error_t inv_free(void *ptr); 52 | inv_error_t inv_create_mutex(HANDLE *mutex); 53 | inv_error_t inv_lock_mutex(HANDLE mutex); 54 | inv_error_t inv_unlock_mutex(HANDLE mutex); 55 | FILE *inv_fopen(char *filename); 56 | void inv_fclose(FILE *fp); 57 | 58 | inv_error_t inv_destroy_mutex(HANDLE handle); 59 | 60 | void inv_sleep(int mSecs); 61 | #ifdef EMPL 62 | inv_error_t inv_get_tick_count(inv_time_t *timestamp); 63 | #else 64 | inv_time_t inv_get_tick_count(void); 65 | #endif 66 | 67 | 68 | /* Kernel implmentations */ 69 | #define GFP_KERNEL (0x70) 70 | static inline void *kmalloc(size_t size, 71 | unsigned int gfp_flags) 72 | { 73 | (void)gfp_flags; 74 | return inv_malloc((unsigned int)size); 75 | } 76 | static inline void *kzalloc(size_t size, unsigned int gfp_flags) 77 | { 78 | void *tmp = inv_malloc((unsigned int)size); 79 | (void)gfp_flags; 80 | if (tmp) 81 | memset(tmp, 0, size); 82 | return tmp; 83 | } 84 | static inline void kfree(void *ptr) 85 | { 86 | inv_free(ptr); 87 | } 88 | static inline void msleep(long msecs) 89 | { 90 | inv_sleep(msecs); 91 | } 92 | static inline void udelay(unsigned long usecs) 93 | { 94 | inv_sleep((usecs + 999) / 1000); 95 | } 96 | #else 97 | #include 98 | #endif 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | #endif /* _MLOS_H */ 104 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/driver/include/stdint_invensense.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | #ifndef STDINT_INVENSENSE_H 7 | #define STDINT_INVENSENSE_H 8 | 9 | #ifndef WIN32 10 | 11 | #if defined __KERNEL__ 12 | #include 13 | #elif defined EMPL 14 | #include 15 | #include 16 | #else 17 | #include 18 | #endif 19 | 20 | #else 21 | 22 | #include 23 | 24 | typedef signed char int8_t; 25 | typedef short int16_t; 26 | typedef long int32_t; 27 | typedef long long int64_t; 28 | 29 | typedef unsigned char uint8_t; 30 | typedef unsigned short uint16_t; 31 | typedef unsigned long uint32_t; 32 | typedef unsigned long long uint64_t; 33 | 34 | typedef int int_fast8_t; 35 | typedef int int_fast16_t; 36 | typedef long int_fast32_t; 37 | 38 | typedef unsigned int uint_fast8_t; 39 | typedef unsigned int uint_fast16_t; 40 | typedef unsigned long uint_fast32_t; 41 | 42 | #endif 43 | 44 | #endif // STDINT_INVENSENSE_H -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/driver/stm32L/packet.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2010 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | /******************************************************************************* 7 | * $Id: $ 8 | *******************************************************************************/ 9 | 10 | /** 11 | * @defgroup STM32L STM32L System Layer 12 | * @brief STM32L System Layer APIs. 13 | * To interface with any platform, eMPL needs access to various 14 | * system layer functions. 15 | * 16 | * @{ 17 | * @file packet.h 18 | * @brief Defines needed for sending data/debug packets via USB. 19 | */ 20 | 21 | #ifndef __PACKET_H__ 22 | #define __PACKET_H__ 23 | 24 | #include "mltypes.h" 25 | 26 | typedef enum { 27 | PACKET_DATA_ACCEL = 0, 28 | PACKET_DATA_GYRO, 29 | PACKET_DATA_COMPASS, 30 | PACKET_DATA_QUAT, 31 | PACKET_DATA_EULER, 32 | PACKET_DATA_ROT, 33 | PACKET_DATA_HEADING, 34 | PACKET_DATA_LINEAR_ACCEL, 35 | NUM_DATA_PACKETS 36 | } eMPL_packet_e; 37 | 38 | /** 39 | * @brief Send a quaternion packet via UART. 40 | * The host is expected to use the data in this packet to graphically 41 | * represent the device orientation. To send quaternion in the same manner 42 | * as any other data packet, use eMPL_send_data. 43 | * @param[in] quat Quaternion data. 44 | */ 45 | void eMPL_send_quat(long *quat); 46 | 47 | /** 48 | * @brief Send a data packet via UART 49 | * @param[in] type Contents of packet (PACKET_DATA_ACCEL, etc). 50 | * @param[in] data Data (length dependent on contents). 51 | */ 52 | void eMPL_send_data(unsigned char type, long *data); 53 | 54 | #endif /* __PACKET_H__ */ 55 | 56 | /** 57 | * @} 58 | */ 59 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/eMPL-hal/eMPL_outputs.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /** 8 | * @defgroup HAL_Outputs 9 | * @brief Motion Library - HAL Outputs 10 | * Sets up common outputs for HAL 11 | * 12 | * @{ 13 | * @file eMPL_outputs.h 14 | * @brief Embedded MPL outputs. 15 | */ 16 | #ifndef _EMPL_OUTPUTS_H_ 17 | #define _EMPL_OUTPUTS_H_ 18 | 19 | #include "mltypes.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | int inv_get_sensor_type_accel(long *data, int8_t *accuracy, inv_time_t *timestamp); 26 | int inv_get_sensor_type_gyro(long *data, int8_t *accuracy, inv_time_t *timestamp); 27 | int inv_get_sensor_type_compass(long *data, int8_t *accuracy, inv_time_t *timestamp); 28 | int inv_get_sensor_type_quat(long *data, int8_t *accuracy, inv_time_t *timestamp); 29 | int inv_get_sensor_type_euler(long *data, int8_t *accuracy, inv_time_t *timestamp); 30 | int inv_get_sensor_type_rot_mat(long *data, int8_t *accuracy, inv_time_t *timestamp); 31 | int inv_get_sensor_type_heading(long *data, int8_t *accuracy, inv_time_t *timestamp); 32 | 33 | inv_error_t inv_enable_eMPL_outputs(void); 34 | inv_error_t inv_disable_eMPL_outputs(void); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* #ifndef _EMPL_OUTPUTS_H_ */ 41 | 42 | /** 43 | * @} 44 | */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/hal_outputs.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #include "mltypes.h" 8 | 9 | #ifndef INV_HAL_OUTPUTS_H__ 10 | #define INV_HAL_OUTPUTS_H__ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | int inv_get_sensor_type_orientation(float *values, int8_t *accuracy, 17 | inv_time_t * timestamp); 18 | int inv_get_sensor_type_accelerometer(float *values, int8_t *accuracy, 19 | inv_time_t * timestamp); 20 | int inv_get_sensor_type_gyroscope(float *values, int8_t *accuracy, 21 | inv_time_t * timestamp); 22 | int inv_get_sensor_type_gyroscope_raw(float *values, int8_t *accuracy, 23 | inv_time_t * timestamp); 24 | int inv_get_sensor_type_magnetic_field(float *values, int8_t *accuracy, 25 | inv_time_t * timestamp); 26 | int inv_get_sensor_type_rotation_vector(float *values, int8_t *accuracy, 27 | inv_time_t * timestamp); 28 | 29 | int inv_get_sensor_type_linear_acceleration(float *values, 30 | int8_t *accuracy, 31 | inv_time_t * timestamp); 32 | int inv_get_sensor_type_gravity(float *values, int8_t *accuracy, 33 | inv_time_t * timestamp); 34 | 35 | inv_error_t inv_enable_hal_outputs(void); 36 | inv_error_t inv_disable_hal_outputs(void); 37 | inv_error_t inv_init_hal_outputs(void); 38 | inv_error_t inv_start_hal_outputs(void); 39 | inv_error_t inv_stop_hal_outputs(void); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif // INV_HAL_OUTPUTS_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/invensense.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | 7 | /******************************************************************************* 8 | * 9 | * $Id:$ 10 | * 11 | ******************************************************************************/ 12 | 13 | /** 14 | * Main header file for Invensense's basic library. 15 | */ 16 | 17 | #include "data_builder.h" 18 | #include "hal_outputs.h" 19 | #include "message_layer.h" 20 | #include "mlmath.h" 21 | #include "ml_math_func.h" 22 | #include "mpl.h" 23 | #include "results_holder.h" 24 | #include "start_manager.h" 25 | #include "storage_manager.h" 26 | #include "log.h" 27 | #include "mlinclude.h" 28 | //#include "..\HAL\include\mlos.h" -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/message_layer.c: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /** 8 | * @defgroup Message_Layer message_layer 9 | * @brief Motion Library - Message Layer 10 | * Holds Low Occurance messages 11 | * 12 | * @{ 13 | * @file message_layer.c 14 | * @brief Holds Low Occurance Messages. 15 | */ 16 | #include "message_layer.h" 17 | #include "log.h" 18 | 19 | struct message_holder_t { 20 | long message; 21 | }; 22 | 23 | static struct message_holder_t mh; 24 | 25 | /** Sets a message. 26 | * @param[in] set The flags to set. 27 | * @param[in] clear Before setting anything this will clear these messages, 28 | * which is useful for mutually exclusive messages such 29 | * a motion or no motion message. 30 | * @param[in] level Level of the messages. It starts at 0, and may increase 31 | * in the future to allow more messages if the bit storage runs out. 32 | */ 33 | void inv_set_message(long set, long clear, int level) 34 | { 35 | if (level == 0) { 36 | mh.message &= ~clear; 37 | mh.message |= set; 38 | } 39 | } 40 | 41 | /** Returns Message Flags for Level 0 Messages. 42 | * Levels are to allow expansion of more messages in the future. 43 | * @param[in] clear If set, will clear the message. Typically this will be set 44 | * for one reader, so that you don't get the same message over and over. 45 | * @return bit field to corresponding message. 46 | */ 47 | long inv_get_message_level_0(int clear) 48 | { 49 | long msg; 50 | msg = mh.message; 51 | if (clear) { 52 | mh.message = 0; 53 | } 54 | return msg; 55 | } 56 | 57 | /** 58 | * @} 59 | */ 60 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/message_layer.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #ifndef INV_MESSAGE_LAYER_H__ 8 | #define INV_MESSAGE_LAYER_H__ 9 | 10 | #include "mltypes.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /* Level 0 Type Messages */ 17 | /** A motion event has occured */ 18 | #define INV_MSG_MOTION_EVENT (0x01) 19 | /** A no motion event has occured */ 20 | #define INV_MSG_NO_MOTION_EVENT (0x02) 21 | /** A setting of the gyro bias has occured */ 22 | #define INV_MSG_NEW_GB_EVENT (0x04) 23 | /** A setting of the compass bias has occured */ 24 | #define INV_MSG_NEW_CB_EVENT (0x08) 25 | /** A setting of the accel bias has occured */ 26 | #define INV_MSG_NEW_AB_EVENT (0x10) 27 | 28 | void inv_set_message(long set, long clear, int level); 29 | long inv_get_message_level_0(int clear); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // INV_MESSAGE_LAYER_H__ 36 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/ml_math_func.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #ifndef INVENSENSE_INV_MATH_FUNC_H__ 8 | #define INVENSENSE_INV_MATH_FUNC_H__ 9 | 10 | #include "mltypes.h" 11 | 12 | #define GYRO_MAG_SQR_SHIFT 6 13 | #define NUM_ROTATION_MATRIX_ELEMENTS (9) 14 | #define ROT_MATRIX_SCALE_LONG (1073741824L) 15 | #define ROT_MATRIX_SCALE_FLOAT (1073741824.0f) 16 | #define ROT_MATRIX_LONG_TO_FLOAT( longval ) \ 17 | ((float) ((longval) / ROT_MATRIX_SCALE_FLOAT )) 18 | #define SIGNM(k)((int)(k)&1?-1:1) 19 | #define SIGNSET(x) ((x) ? -1 : +1) 20 | 21 | #define INV_TWO_POWER_NEG_30 9.313225746154785e-010f 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef struct { 28 | float state[4]; 29 | float c[5]; 30 | float input; 31 | float output; 32 | } inv_biquad_filter_t; 33 | 34 | static inline float inv_q30_to_float(long q30) 35 | { 36 | return (float) q30 / ((float)(1L << 30)); 37 | } 38 | 39 | static inline double inv_q30_to_double(long q30) 40 | { 41 | return (double) q30 / ((double)(1L << 30)); 42 | } 43 | 44 | static inline float inv_q16_to_float(long q16) 45 | { 46 | return (float) q16 / (1L << 16); 47 | } 48 | 49 | static inline double inv_q16_to_double(long q16) 50 | { 51 | return (double) q16 / (1L << 16); 52 | } 53 | 54 | 55 | 56 | 57 | long inv_q29_mult(long a, long b); 58 | long inv_q30_mult(long a, long b); 59 | 60 | /* UMPL_ELIMINATE_64BIT Notes: 61 | * An alternate implementation using float instead of long long accudoublemulators 62 | * is provided for q29_mult and q30_mult. 63 | * When long long accumulators are used and an alternate implementation is not 64 | * available, we eliminate the entire function and header with a macro. 65 | */ 66 | #ifndef UMPL_ELIMINATE_64BIT 67 | long inv_q30_div(long a, long b); 68 | long inv_q_shift_mult(long a, long b, int shift); 69 | #endif 70 | 71 | void inv_q_mult(const long *q1, const long *q2, long *qProd); 72 | void inv_q_add(long *q1, long *q2, long *qSum); 73 | void inv_q_normalize(long *q); 74 | void inv_q_invert(const long *q, long *qInverted); 75 | void inv_q_multf(const float *q1, const float *q2, float *qProd); 76 | void inv_q_addf(const float *q1, const float *q2, float *qSum); 77 | void inv_q_normalizef(float *q); 78 | void inv_q_norm4(float *q); 79 | void inv_q_invertf(const float *q, float *qInverted); 80 | void inv_quaternion_to_rotation(const long *quat, long *rot); 81 | unsigned char *inv_int32_to_big8(long x, unsigned char *big8); 82 | long inv_big8_to_int32(const unsigned char *big8); 83 | short inv_big8_to_int16(const unsigned char *big8); 84 | short inv_little8_to_int16(const unsigned char *little8); 85 | unsigned char *inv_int16_to_big8(short x, unsigned char *big8); 86 | float inv_matrix_det(float *p, int *n); 87 | void inv_matrix_det_inc(float *a, float *b, int *n, int x, int y); 88 | double inv_matrix_detd(double *p, int *n); 89 | void inv_matrix_det_incd(double *a, double *b, int *n, int x, int y); 90 | float inv_wrap_angle(float ang); 91 | float inv_angle_diff(float ang1, float ang2); 92 | void inv_quaternion_to_rotation_vector(const long *quat, long *rot); 93 | unsigned short inv_orientation_matrix_to_scalar(const signed char *mtx); 94 | void inv_convert_to_body(unsigned short orientation, const long *input, long *output); 95 | void inv_convert_to_chip(unsigned short orientation, const long *input, long *output); 96 | void inv_convert_to_body_with_scale(unsigned short orientation, long sensitivity, const long *input, long *output); 97 | void inv_q_rotate(const long *q, const long *in, long *out); 98 | void inv_vector_normalize(long *vec, int length); 99 | uint32_t inv_checksum(const unsigned char *str, int len); 100 | float inv_compass_angle(const long *compass, const long *grav, 101 | const long *quat); 102 | unsigned long inv_get_gyro_sum_of_sqr(const long *gyro); 103 | 104 | #ifdef EMPL 105 | float inv_sinf(float x); 106 | float inv_cosf(float x); 107 | /* eMPL timestamps are assumed to be in milliseconds. */ 108 | static inline long inv_delta_time_ms(inv_time_t t1, inv_time_t t2) 109 | { 110 | return (long)((t1 - t2)); 111 | } 112 | #else 113 | static inline long inv_delta_time_ms(inv_time_t t1, inv_time_t t2) 114 | { 115 | return (long)((t1 - t2) / 1000000L); 116 | } 117 | #endif 118 | 119 | double quaternion_to_rotation_angle(const long *quat); 120 | double inv_vector_norm(const float *x); 121 | 122 | void inv_init_biquad_filter(inv_biquad_filter_t *pFilter, float *pBiquadCoeff); 123 | float inv_biquad_filter_process(inv_biquad_filter_t *pFilter, float input); 124 | void inv_calc_state_to_match_output(inv_biquad_filter_t *pFilter, float input); 125 | void inv_get_cross_product_vec(float *cgcross, float compass[3], float grav[3]); 126 | 127 | void mlMatrixVectorMult(long matrix[9], const long vecIn[3], long *vecOut); 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | #endif // INVENSENSE_INV_MATH_FUNC_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/mlmath.c: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /******************************************************************************* 8 | * 9 | * $Id: mlmath.c 5629 2011-06-11 03:13:08Z mcaramello $ 10 | * 11 | *******************************************************************************/ 12 | 13 | #include 14 | 15 | double ml_asin(double x) 16 | { 17 | return asin(x); 18 | } 19 | 20 | double ml_atan(double x) 21 | { 22 | return atan(x); 23 | } 24 | 25 | double ml_atan2(double x, double y) 26 | { 27 | return atan2(x, y); 28 | } 29 | 30 | double ml_log(double x) 31 | { 32 | return log(x); 33 | } 34 | 35 | double ml_sqrt(double x) 36 | { 37 | return sqrt(x); 38 | } 39 | 40 | double ml_ceil(double x) 41 | { 42 | return ceil(x); 43 | } 44 | 45 | double ml_floor(double x) 46 | { 47 | return floor(x); 48 | } 49 | 50 | double ml_cos(double x) 51 | { 52 | return cos(x); 53 | } 54 | 55 | double ml_sin(double x) 56 | { 57 | return sin(x); 58 | } 59 | 60 | double ml_acos(double x) 61 | { 62 | return acos(x); 63 | } 64 | 65 | double ml_pow(double x, double y) 66 | { 67 | return pow(x, y); 68 | } -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/mpl.c: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | /** 8 | * @defgroup MPL mpl 9 | * @brief Motion Library - Start Point 10 | * Initializes MPL. 11 | * 12 | * @{ 13 | * @file mpl.c 14 | * @brief MPL start point. 15 | */ 16 | 17 | #include "storage_manager.h" 18 | #include "log.h" 19 | #include "mpl.h" 20 | #include "start_manager.h" 21 | #include "data_builder.h" 22 | #include "results_holder.h" 23 | #include "mlinclude.h" 24 | 25 | /** 26 | * @brief Initializes the MPL. Should be called first and once 27 | * @return Returns INV_SUCCESS if successful or an error code if not. 28 | */ 29 | inv_error_t inv_init_mpl(void) 30 | { 31 | inv_init_storage_manager(); 32 | 33 | /* initialize the start callback manager */ 34 | INV_ERROR_CHECK(inv_init_start_manager()); 35 | 36 | /* initialize the data builder */ 37 | INV_ERROR_CHECK(inv_init_data_builder()); 38 | 39 | INV_ERROR_CHECK(inv_enable_results_holder()); 40 | 41 | return INV_SUCCESS; 42 | } 43 | 44 | const char ml_ver[] = "InvenSense MA 5.1.2"; 45 | 46 | /** 47 | * @brief used to get the MPL version. 48 | * @param version a string where the MPL version gets stored. 49 | * @return INV_SUCCESS if successful or a non-zero error code otherwise. 50 | */ 51 | inv_error_t inv_get_version(char **version) 52 | { 53 | INVENSENSE_FUNC_START; 54 | /* cast out the const */ 55 | *version = (char *)&ml_ver; 56 | return INV_SUCCESS; 57 | } 58 | 59 | /** 60 | * @brief Starts the MPL. Typically called after inv_init_mpl() or after a 61 | * inv_stop_mpl() to start the MPL back up an running. 62 | * @return INV_SUCCESS if successful or a non-zero error code otherwise. 63 | */ 64 | inv_error_t inv_start_mpl(void) 65 | { 66 | INV_ERROR_CHECK(inv_execute_mpl_start_notification()); 67 | return INV_SUCCESS; 68 | } 69 | 70 | /** 71 | * @} 72 | */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/mpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #include "mltypes.h" 8 | 9 | #ifndef INV_MPL_H__ 10 | #define INV_MPL_H__ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | inv_error_t inv_init_mpl(void); 17 | inv_error_t inv_start_mpl(void); 18 | inv_error_t inv_get_version(char **version); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif // INV_MPL_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/results_holder.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #include "mltypes.h" 8 | 9 | #ifndef INV_RESULTS_HOLDER_H__ 10 | #define INV_RESULTS_HOLDER_H__ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #define INV_MOTION 0x0001 17 | #define INV_NO_MOTION 0x0002 18 | 19 | /**************************************************************************/ 20 | /* The value of inv_get_gyro_sum_of_sqr is scaled such the (1 dps)^2 = */ 21 | /* 2^GYRO_MAG_SQR_SHIFT. This number must be >=0 and even. */ 22 | /* The value of inv_accel_sum_of_sqr is scaled such that (1g)^2 = */ 23 | /* 2^ACC_MAG_SQR_SHIFT */ 24 | /**************************************************************************/ 25 | #define ACC_MAG_SQR_SHIFT 16 26 | 27 | void inv_store_gaming_quaternion(const long *quat, inv_time_t timestamp); 28 | 29 | // States 30 | #define SF_NORMAL 0 31 | #define SF_UNCALIBRATED 1 32 | #define SF_STARTUP_SETTLE 2 33 | #define SF_FAST_SETTLE 3 34 | #define SF_DISTURBANCE 4 35 | #define SF_SLOW_SETTLE 5 36 | 37 | int inv_get_acc_state(void); 38 | void inv_set_acc_state(int state); 39 | int inv_get_motion_state(unsigned int *cntr); 40 | void inv_set_motion_state(unsigned char state); 41 | inv_error_t inv_get_gravity(long *data); 42 | inv_error_t inv_get_6axis_quaternion(long *data); 43 | inv_error_t inv_get_quaternion(long *data); 44 | inv_error_t inv_get_quaternion_float(float *data); 45 | void inv_get_quaternion_set(long *data, int *accuracy, inv_time_t *timestamp); 46 | 47 | inv_error_t inv_enable_results_holder(void); 48 | inv_error_t inv_init_results_holder(void); 49 | 50 | /* Magnetic Field Parameters*/ 51 | void inv_set_local_field(const long *data); 52 | void inv_get_local_field(long *data); 53 | void inv_set_mag_scale(const long *data); 54 | void inv_get_mag_scale(long *data); 55 | void inv_set_compass_correction(const long *data, inv_time_t timestamp); 56 | void inv_get_compass_correction(long *data, inv_time_t *timestamp); 57 | int inv_got_compass_bias(void); 58 | void inv_set_compass_bias_found(int state); 59 | int inv_get_large_mag_field(void); 60 | void inv_set_large_mag_field(int state); 61 | void inv_set_compass_state(int state); 62 | int inv_get_compass_state(void); 63 | void inv_set_compass_bias_error(const long *bias_error); 64 | void inv_get_compass_bias_error(long *bias_error); 65 | inv_error_t inv_get_linear_accel(long *data); 66 | inv_error_t inv_get_accel(long *data); 67 | inv_error_t inv_get_accel_float(float *data); 68 | inv_error_t inv_get_gyro_float(float *data); 69 | inv_error_t inv_get_linear_accel_float(float *data); 70 | void inv_set_heading_confidence_interval(float ci); 71 | float inv_get_heading_confidence_interval(void); 72 | 73 | int inv_got_accel_bias(void); 74 | void inv_set_accel_bias_found(int state); 75 | 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif // INV_RESULTS_HOLDER_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/start_manager.c: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /******************************************************************************* 9 | * 10 | * $Id:$ 11 | * 12 | ******************************************************************************/ 13 | /** 14 | * @defgroup Start_Manager start_manager 15 | * @brief Motion Library - Start Manager 16 | * Start Manager 17 | * 18 | * @{ 19 | * @file start_manager.c 20 | * @brief This handles all the callbacks when inv_start_mpl() is called. 21 | */ 22 | 23 | 24 | #include 25 | #include "log.h" 26 | #include "start_manager.h" 27 | 28 | typedef inv_error_t (*inv_start_cb_func)(); 29 | struct inv_start_cb_t { 30 | int num_cb; 31 | inv_start_cb_func start_cb[INV_MAX_START_CB]; 32 | }; 33 | 34 | static struct inv_start_cb_t inv_start_cb; 35 | 36 | /** Initilize the start manager. Typically called by inv_start_mpl(); 37 | * @return Returns INV_SUCCESS if successful or an error code if not. 38 | */ 39 | inv_error_t inv_init_start_manager(void) 40 | { 41 | memset(&inv_start_cb, 0, sizeof(inv_start_cb)); 42 | return INV_SUCCESS; 43 | } 44 | 45 | /** Removes a callback from start notification 46 | * @param[in] start_cb function to remove from start notification 47 | * @return Returns INV_SUCCESS if successful or an error code if not. 48 | */ 49 | inv_error_t inv_unregister_mpl_start_notification(inv_error_t (*start_cb)(void)) 50 | { 51 | int kk; 52 | 53 | for (kk=0; kk= INV_MAX_START_CB) 76 | return INV_ERROR_INVALID_PARAMETER; 77 | 78 | inv_start_cb.start_cb[inv_start_cb.num_cb] = start_cb; 79 | inv_start_cb.num_cb++; 80 | return INV_SUCCESS; 81 | } 82 | 83 | /** Callback all the functions that want to be notified when inv_start_mpl() was 84 | * called. 85 | * @return Returns INV_SUCCESS if successful or an error code if not. 86 | */ 87 | inv_error_t inv_execute_mpl_start_notification(void) 88 | { 89 | inv_error_t result,first_error; 90 | int kk; 91 | 92 | first_error = INV_SUCCESS; 93 | 94 | for (kk = 0; kk < inv_start_cb.num_cb; ++kk) { 95 | result = inv_start_cb.start_cb[kk](); 96 | if (result && (first_error == INV_SUCCESS)) { 97 | first_error = result; 98 | } 99 | } 100 | return first_error; 101 | } 102 | 103 | /** 104 | * @} 105 | */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/start_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #ifndef INV_START_MANAGER_H__ 8 | #define INV_START_MANAGER_H__ 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #include "mltypes.h" 15 | 16 | /** Max number of start callbacks we can handle. */ 17 | #define INV_MAX_START_CB 20 18 | 19 | inv_error_t inv_init_start_manager(void); 20 | inv_error_t inv_register_mpl_start_notification(inv_error_t (*start_cb)(void)); 21 | inv_error_t inv_execute_mpl_start_notification(void); 22 | inv_error_t inv_unregister_mpl_start_notification(inv_error_t (*start_cb)(void)); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | #endif // INV_START_MANAGER_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mllite/storage_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #include "mltypes.h" 8 | 9 | #ifndef INV_STORAGE_MANAGER_H__ 10 | #define INV_STORAGE_MANAGER_H__ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | inv_error_t inv_register_load_store( 17 | inv_error_t (*load_func)(const unsigned char *data), 18 | inv_error_t (*save_func)(unsigned char *data), 19 | size_t size, unsigned int key); 20 | void inv_init_storage_manager(void); 21 | 22 | inv_error_t inv_get_mpl_state_size(size_t *size); 23 | inv_error_t inv_load_mpl_states(const unsigned char *data, size_t len); 24 | inv_error_t inv_save_mpl_states(unsigned char *data, size_t len); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif /* INV_STORAGE_MANAGER_H__ */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/accel_auto_cal.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /******************************************************************************* 9 | * 10 | * $Id$ 11 | * 12 | ******************************************************************************/ 13 | 14 | #ifndef MLDMP_ACCEL_AUTO_CALIBRATION_H__ 15 | #define MLDMP_ACCEL_AUTO_CALIBRATION_H__ 16 | 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | inv_error_t inv_enable_in_use_auto_calibration(void); 24 | inv_error_t inv_disable_in_use_auto_calibration(void); 25 | inv_error_t inv_stop_in_use_auto_calibration(void); 26 | inv_error_t inv_start_in_use_auto_calibration(void); 27 | inv_error_t inv_in_use_auto_calibration_is_enabled(unsigned char *is_enabled); 28 | inv_error_t inv_init_in_use_auto_calibration(void); 29 | void inv_init_accel_maxmin(void); 30 | void inv_record_good_accel_maxmin(void); 31 | int inv_get_accel_bias_stage(void); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // MLDMP_ACCEL_AUTO_CALIBRATION_H__ 38 | 39 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/compass_vec_cal.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /******************************************************************************* 9 | * 10 | * $Id:$ 11 | * 12 | ******************************************************************************/ 13 | 14 | #ifndef COMPASS_ONLY_CAL_H__ 15 | #define COMPASS_ONLY_CAL_H__ 16 | 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | inv_error_t inv_enable_vector_compass_cal(void); 24 | inv_error_t inv_disable_vector_compass_cal(void); 25 | inv_error_t inv_start_vector_compass_cal(void); 26 | inv_error_t inv_stop_vector_compass_cal(void); 27 | void inv_vector_compass_cal_sensitivity(float sens); 28 | inv_error_t inv_init_vector_compass_cal(void); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // COMPASS_ONLY_CAL_H__ 35 | 36 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/fast_no_motion.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /****************************************************************************** 9 | * 10 | * $Id$ 11 | * 12 | *****************************************************************************/ 13 | 14 | #ifndef MLDMP_FAST_NO_MOTION_H__ 15 | #define MLDMP_FAST_NO_MOTION_H__ 16 | 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | inv_error_t inv_enable_fast_nomot(void); 24 | inv_error_t inv_disable_fast_nomot(void); 25 | inv_error_t inv_start_fast_nomot(void); 26 | inv_error_t inv_stop_fast_nomot(void); 27 | inv_error_t inv_init_fast_nomot(void); 28 | void inv_set_default_number_of_samples(int count); 29 | inv_error_t inv_fast_nomot_is_enabled(unsigned char *is_enabled); 30 | inv_error_t inv_update_fast_nomot(long *gyro); 31 | 32 | void inv_get_fast_nomot_accel_param(long *cntr, long long *param); 33 | void inv_get_fast_nomot_compass_param(long *cntr, long long *param); 34 | void inv_set_fast_nomot_accel_threshold(long long thresh); 35 | void inv_set_fast_nomot_compass_threshold(long long thresh); 36 | void int_set_fast_nomot_gyro_threshold(long long thresh); 37 | 38 | void inv_fnm_debug_print(void); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | 45 | #endif // MLDMP_FAST_NO_MOTION_H__ 46 | 47 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/fusion_9axis.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /****************************************************************************** 9 | * 10 | * $Id$ 11 | * 12 | *****************************************************************************/ 13 | 14 | #ifndef MLDMP_FUSION9AXIS_H__ 15 | #define MLDMP_FUSION9AXIS_H__ 16 | 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | void inv_init_9x_fusion(void); 24 | inv_error_t inv_9x_fusion_state_change(unsigned char newState); 25 | inv_error_t inv_enable_9x_sensor_fusion(void); 26 | inv_error_t inv_disable_9x_sensor_fusion(void); 27 | inv_error_t inv_start_9x_sensor_fusion(void); 28 | inv_error_t inv_stop_9x_sensor_fusion(void); 29 | inv_error_t inv_9x_fusion_set_mag_fb(float fb); 30 | inv_error_t inv_9x_fusion_enable_jitter_reduction(int en); 31 | inv_error_t inv_9x_fusion_use_timestamps(int en); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | 38 | #endif // MLDMP_FUSION9AXIS_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/gyro_tc.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /****************************************************************************** 9 | * 10 | * $Id$ 11 | * 12 | *****************************************************************************/ 13 | 14 | #ifndef _GYRO_TC_H 15 | #define _GYRO_TC_H_ 16 | 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | inv_error_t inv_enable_gyro_tc(void); 24 | inv_error_t inv_disable_gyro_tc(void); 25 | inv_error_t inv_start_gyro_tc(void); 26 | inv_error_t inv_stop_gyro_tc(void); 27 | 28 | inv_error_t inv_get_gyro_ts(long *data); 29 | inv_error_t inv_set_gyro_ts(long *data); 30 | 31 | inv_error_t inv_init_gyro_ts(void); 32 | 33 | inv_error_t inv_set_gtc_max_temp(long data); 34 | inv_error_t inv_set_gtc_min_temp(long data); 35 | 36 | inv_error_t inv_print_gtc_data(void); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* _GYRO_TC_H */ 43 | 44 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/heading_from_gyro.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | /****************************************************************************** 9 | * 10 | * $Id$ 11 | * 12 | *****************************************************************************/ 13 | 14 | #ifndef _HEADING_FROM_GYRO_H_ 15 | #define _HEADING_FROM_GYRO_H_ 16 | #include "mltypes.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | inv_error_t inv_enable_heading_from_gyro(void); 23 | inv_error_t inv_disable_heading_from_gyro(void); 24 | void inv_init_heading_from_gyro(void); 25 | inv_error_t inv_start_heading_from_gyro(void); 26 | inv_error_t inv_stop_heading_from_gyro(void); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | 33 | #endif /* _HEADING_FROM_GYRO_H_ */ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/inv_math.h: -------------------------------------------------------------------------------- 1 | /* math.h has many functions and defines that are not consistent across 2 | * platforms. This address that */ 3 | 4 | #ifdef _WINDOWS 5 | #define _USE_MATH_DEFINES 6 | #endif 7 | 8 | #include -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/invensense_adv.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2012 InvenSense Corporation, All Rights Reserved. 4 | $ 5 | */ 6 | 7 | /******************************************************************************* 8 | * 9 | * $Id:$ 10 | * 11 | ******************************************************************************/ 12 | 13 | /* 14 | Main header file for Invensense's Advanced library. 15 | */ 16 | 17 | #include "accel_auto_cal.h" 18 | #include "compass_vec_cal.h" 19 | #include "fast_no_motion.h" 20 | #include "fusion_9axis.h" 21 | #include "gyro_tc.h" 22 | #include "heading_from_gyro.h" 23 | #include "mag_disturb.h" 24 | #include "motion_no_motion.h" 25 | #include "no_gyro_fusion.h" 26 | #include "quaternion_supervisor.h" 27 | #include "mag_disturb.h" -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/mag_disturb.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | #ifndef MLDMP_MAGDISTURB_H__ 9 | #define MLDMP_MAGDISTURB_H__ 10 | 11 | #include "mltypes.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | int inv_check_magnetic_disturbance(unsigned long delta_time, const long *quat, 18 | const long *compass, const long *gravity); 19 | 20 | void inv_track_dip_angle(int mode, float currdip); 21 | 22 | inv_error_t inv_enable_magnetic_disturbance(void); 23 | inv_error_t inv_disable_magnetic_disturbance(void); 24 | int inv_get_magnetic_disturbance_state(void); 25 | inv_error_t inv_set_magnetic_disturbance(int time_ms); 26 | inv_error_t inv_disable_dip_tracking(void); 27 | inv_error_t inv_enable_dip_tracking(void); 28 | inv_error_t inv_init_magnetic_disturbance(void); 29 | 30 | float Mag3ofNormalizedLong(const long *x); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | 37 | #endif // MLDMP_MAGDISTURB_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/motion_no_motion.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #ifndef INV_MOTION_NO_MOTION_H__ 8 | #define INV_MOTION_NO_MOTION_H__ 9 | 10 | #include "mltypes.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | inv_error_t inv_enable_motion_no_motion(void); 17 | inv_error_t inv_disable_motion_no_motion(void); 18 | inv_error_t inv_init_motion_no_motion(void); 19 | inv_error_t inv_start_motion_no_motion(void); 20 | inv_error_t inv_stop_motion_no_motion(void); 21 | 22 | inv_error_t inv_set_no_motion_time(long time_ms); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif // INV_MOTION_NO_MOTION_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/no_gyro_fusion.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | 8 | 9 | /****************************************************************************** 10 | * 11 | * $Id$ 12 | * 13 | *****************************************************************************/ 14 | 15 | #ifndef MLDMP_NOGYROFUSION_H__ 16 | #define MLDMP_NOGYROFUSION_H__ 17 | #include "mltypes.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | inv_error_t inv_enable_no_gyro_fusion(void); 24 | inv_error_t inv_disable_no_gyro_fusion(void); 25 | inv_error_t inv_start_no_gyro_fusion(void); 26 | inv_error_t inv_start_no_gyro_fusion(void); 27 | inv_error_t inv_init_no_gyro_fusion(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | 34 | #endif // MLDMP_NOGYROFUSION_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/core_orig/mpl/quaternion_supervisor.h: -------------------------------------------------------------------------------- 1 | /* 2 | $License: 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 | See included License.txt for License information. 5 | $ 6 | */ 7 | #ifndef INV_QUATERNION_SUPERVISOR_H__ 8 | #define INV_QUATERNION_SUPERVISOR_H__ 9 | 10 | #include "mltypes.h" 11 | 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | inv_error_t inv_enable_quaternion(void); 18 | inv_error_t inv_disable_quaternion(void); 19 | inv_error_t inv_init_quaternion(void); 20 | inv_error_t inv_start_quaternion(void); 21 | void inv_set_quaternion(long *quat); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif // INV_QUATERNION_SUPERVISOR_H__ -------------------------------------------------------------------------------- /external/motion_driver_6.12/eMPL-pythonclient/ponycube.py: -------------------------------------------------------------------------------- 1 | # Rotate a cube with a quaternion 2 | # Demo program 3 | # Pat Hickey, 27 Dec 10 4 | # This code is in the public domain. 5 | 6 | import pygame 7 | import pygame.draw 8 | import pygame.time 9 | from math import sin, cos, acos 10 | from euclid import * 11 | 12 | class Screen (object): 13 | def __init__(self,x=320,y=280,scale=1): 14 | self.i = pygame.display.set_mode((x,y)) 15 | self.originx = self.i.get_width() / 2 16 | self.originy = self.i.get_height() / 2 17 | self.scale = scale 18 | 19 | def project(self,v): 20 | assert isinstance(v,Vector3) 21 | x = v.x * self.scale + self.originx 22 | y = v.y * self.scale + self.originy 23 | return (x,y) 24 | def depth(self,v): 25 | assert isinstance(v,Vector3) 26 | return v.z 27 | 28 | class PrespectiveScreen(Screen): 29 | # the xy projection and depth functions are really an orthonormal space 30 | # but here i just approximated it with decimals to keep it quick n dirty 31 | def project(self,v): 32 | assert isinstance(v,Vector3) 33 | x = ((v.x*0.957) + (v.z*0.287)) * self.scale + self.originx 34 | y = ((v.y*0.957) + (v.z*0.287)) * self.scale + self.originy 35 | return (x,y) 36 | def depth(self,v): 37 | assert isinstance(v,Vector3) 38 | z = (v.z*0.9205) - (v.x*0.276) - (v.y*0.276) 39 | return z 40 | 41 | class Side (object): 42 | def __init__(self,a,b,c,d,color=(50,0,0)): 43 | assert isinstance(a,Vector3) 44 | assert isinstance(b,Vector3) 45 | assert isinstance(c,Vector3) 46 | assert isinstance(d,Vector3) 47 | self.a = a 48 | self.b = b 49 | self.c = c 50 | self.d = d 51 | self.color = color 52 | 53 | def centroid(self): 54 | return ( self.a + self.b + self.c + self.d ) / 4 55 | 56 | def draw(self,screen): 57 | assert isinstance(screen,Screen) 58 | s = [ screen.project(self.a) 59 | , screen.project(self.b) 60 | , screen.project(self.c) 61 | , screen.project(self.d) 62 | ] 63 | pygame.draw.polygon(screen.i,self.color,s) 64 | 65 | def erase(self,screen,clear_color = (0,0,0)): 66 | c = self.color 67 | self.color = clear_color 68 | self.draw(screen) 69 | self.color = c 70 | 71 | class Edge (object): 72 | def __init__(self,a,b,color=(0,0,255)): 73 | assert isinstance(a,Vector3) 74 | assert isinstance(b,Vector3) 75 | self.a = a 76 | self.b = b 77 | self.color = color 78 | def centroid(self): 79 | return (self.a + self.b) / 2 80 | def draw(self,screen): 81 | assert isinstance(screen,Screen) 82 | aa = screen.project(self.a) 83 | bb = screen.project(self.b) 84 | pygame.draw.line(screen.i, self.color, aa,bb) 85 | def erase(self,screen,clear_color = (0,0,0)): 86 | c = self.color 87 | self.color = clear_color 88 | self.draw(screen) 89 | self.color = c 90 | 91 | 92 | 93 | class Cube (object): 94 | def __init__(self,a=10,b=10,c=10): 95 | self.a = a 96 | self.b = b 97 | self.c = c 98 | self.pts = [ Vector3(-a,b,c) , Vector3(a,b,c) 99 | , Vector3(a,-b,c) , Vector3(-a,-b,c) 100 | , Vector3(-a,b,-c) , Vector3(a,b,-c) 101 | , Vector3(a,-b,-c) , Vector3(-a,-b,-c) ] 102 | 103 | def origin(self): 104 | """ reset self.pts to the origin, so we can give them a new rotation """ 105 | a = self.a; b = self.b; c = self.c 106 | self.pts = [ Vector3(-a,b,c) , Vector3(a,b,c) 107 | , Vector3(a,-b,c) , Vector3(-a,-b,c) 108 | , Vector3(-a,b,-c) , Vector3(a,b,-c) 109 | , Vector3(a,-b,-c) , Vector3(-a,-b,-c) ] 110 | 111 | def sides(self): 112 | """ each side is a Side object of a certain color """ 113 | # leftright = (80,80,150) # color 114 | # topbot = (30,30,150) 115 | # frontback = (0,0,150) 116 | one = (255, 0, 0) 117 | two = (0, 255, 0) 118 | three = (0, 0, 255) 119 | four = (255, 255, 0) 120 | five = (0, 255, 255) 121 | six = (255, 0, 255) 122 | a, b, c, d, e, f, g, h = self.pts 123 | sides = [ Side( a, b, c, d, one) # front 124 | , Side( e, f, g, h, two) # back 125 | , Side( a, e, f, b, three) # bottom 126 | , Side( b, f, g, c, four) # right 127 | , Side( c, g, h, d, five) # top 128 | , Side( d, h, e, a, six) # left 129 | ] 130 | return sides 131 | 132 | def edges(self): 133 | """ each edge is drawn as well """ 134 | ec = (0,0,255) # color 135 | a, b, c, d, e, f, g, h = self.pts 136 | edges = [ Edge(a,b,ec), Edge(b,c,ec), Edge(c,d,ec), Edge(d,a,ec) 137 | , Edge(e,f,ec), Edge(f,g,ec), Edge(g,h,ec), Edge(h,e,ec) 138 | , Edge(a,e,ec), Edge(b,f,ec), Edge(c,g,ec), Edge(d,h,ec) 139 | ] 140 | return edges 141 | 142 | def erase(self,screen): 143 | """ erase object at present rotation (last one drawn to screen) """ 144 | assert isinstance(screen,Screen) 145 | sides = self.sides() 146 | edges = self.edges() 147 | erasables = sides + edges 148 | [ s.erase(screen) for s in erasables] 149 | 150 | def draw(self,screen,q=Quaternion(1,0,0,0)): 151 | """ draw object at given rotation """ 152 | assert isinstance(screen,Screen) 153 | self.origin() 154 | self.rotate(q) 155 | sides = self.sides() 156 | edges = self.edges() 157 | drawables = sides + edges 158 | drawables.sort(key=lambda s: screen.depth(s.centroid())) 159 | [ s.draw(screen) for s in drawables ] 160 | 161 | def rotate(self,q): 162 | assert isinstance(q,Quaternion) 163 | R = q.get_matrix() 164 | self.pts = [R*p for p in self.pts] 165 | 166 | if __name__ == "__main__": 167 | pygame.init() 168 | screen = Screen(480,400,scale=1.5) 169 | cube = Cube(40,30,60) 170 | q = Quaternion(1,0,0,0) 171 | incr = Quaternion(0.96,0.01,0.01,0).normalized() 172 | 173 | while 1: 174 | q = q * incr 175 | cube.draw(screen,q) 176 | event = pygame.event.poll() 177 | if event.type == pygame.QUIT \ 178 | or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE): 179 | break 180 | pygame.display.flip() 181 | pygame.time.delay(50) 182 | cube.erase(screen) 183 | 184 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/eMPL-pythonclient_orig/ponycube.py: -------------------------------------------------------------------------------- 1 | # Rotate a cube with a quaternion 2 | # Demo program 3 | # Pat Hickey, 27 Dec 10 4 | # This code is in the public domain. 5 | 6 | import pygame 7 | import pygame.draw 8 | import pygame.time 9 | from math import sin, cos, acos 10 | from euclid import * 11 | 12 | class Screen (object): 13 | def __init__(self,x=320,y=280,scale=1): 14 | self.i = pygame.display.set_mode((x,y)) 15 | self.originx = self.i.get_width() / 2 16 | self.originy = self.i.get_height() / 2 17 | self.scale = scale 18 | 19 | def project(self,v): 20 | assert isinstance(v,Vector3) 21 | x = v.x * self.scale + self.originx 22 | y = v.y * self.scale + self.originy 23 | return (x,y) 24 | def depth(self,v): 25 | assert isinstance(v,Vector3) 26 | return v.z 27 | 28 | class PrespectiveScreen(Screen): 29 | # the xy projection and depth functions are really an orthonormal space 30 | # but here i just approximated it with decimals to keep it quick n dirty 31 | def project(self,v): 32 | assert isinstance(v,Vector3) 33 | x = ((v.x*0.957) + (v.z*0.287)) * self.scale + self.originx 34 | y = ((v.y*0.957) + (v.z*0.287)) * self.scale + self.originy 35 | return (x,y) 36 | def depth(self,v): 37 | assert isinstance(v,Vector3) 38 | z = (v.z*0.9205) - (v.x*0.276) - (v.y*0.276) 39 | return z 40 | 41 | class Side (object): 42 | def __init__(self,a,b,c,d,color=(50,0,0)): 43 | assert isinstance(a,Vector3) 44 | assert isinstance(b,Vector3) 45 | assert isinstance(c,Vector3) 46 | assert isinstance(d,Vector3) 47 | self.a = a 48 | self.b = b 49 | self.c = c 50 | self.d = d 51 | self.color = color 52 | 53 | def centroid(self): 54 | return ( self.a + self.b + self.c + self.d ) / 4 55 | 56 | def draw(self,screen): 57 | assert isinstance(screen,Screen) 58 | s = [ screen.project(self.a) 59 | , screen.project(self.b) 60 | , screen.project(self.c) 61 | , screen.project(self.d) 62 | ] 63 | pygame.draw.polygon(screen.i,self.color,s) 64 | 65 | def erase(self,screen,clear_color = (0,0,0)): 66 | c = self.color 67 | self.color = clear_color 68 | self.draw(screen) 69 | self.color = c 70 | 71 | class Edge (object): 72 | def __init__(self,a,b,color=(0,0,255)): 73 | assert isinstance(a,Vector3) 74 | assert isinstance(b,Vector3) 75 | self.a = a 76 | self.b = b 77 | self.color = color 78 | def centroid(self): 79 | return (self.a + self.b) / 2 80 | def draw(self,screen): 81 | assert isinstance(screen,Screen) 82 | aa = screen.project(self.a) 83 | bb = screen.project(self.b) 84 | pygame.draw.line(screen.i, self.color, aa,bb) 85 | def erase(self,screen,clear_color = (0,0,0)): 86 | c = self.color 87 | self.color = clear_color 88 | self.draw(screen) 89 | self.color = c 90 | 91 | 92 | 93 | class Cube (object): 94 | def __init__(self,a=10,b=10,c=10): 95 | self.a = a 96 | self.b = b 97 | self.c = c 98 | self.pts = [ Vector3(-a,b,c) , Vector3(a,b,c) 99 | , Vector3(a,-b,c) , Vector3(-a,-b,c) 100 | , Vector3(-a,b,-c) , Vector3(a,b,-c) 101 | , Vector3(a,-b,-c) , Vector3(-a,-b,-c) ] 102 | 103 | def origin(self): 104 | """ reset self.pts to the origin, so we can give them a new rotation """ 105 | a = self.a; b = self.b; c = self.c 106 | self.pts = [ Vector3(-a,b,c) , Vector3(a,b,c) 107 | , Vector3(a,-b,c) , Vector3(-a,-b,c) 108 | , Vector3(-a,b,-c) , Vector3(a,b,-c) 109 | , Vector3(a,-b,-c) , Vector3(-a,-b,-c) ] 110 | 111 | def sides(self): 112 | """ each side is a Side object of a certain color """ 113 | # leftright = (80,80,150) # color 114 | # topbot = (30,30,150) 115 | # frontback = (0,0,150) 116 | one = (255, 0, 0) 117 | two = (0, 255, 0) 118 | three = (0, 0, 255) 119 | four = (255, 255, 0) 120 | five = (0, 255, 255) 121 | six = (255, 0, 255) 122 | a, b, c, d, e, f, g, h = self.pts 123 | sides = [ Side( a, b, c, d, one) # front 124 | , Side( e, f, g, h, two) # back 125 | , Side( a, e, f, b, three) # bottom 126 | , Side( b, f, g, c, four) # right 127 | , Side( c, g, h, d, five) # top 128 | , Side( d, h, e, a, six) # left 129 | ] 130 | return sides 131 | 132 | def edges(self): 133 | """ each edge is drawn as well """ 134 | ec = (0,0,255) # color 135 | a, b, c, d, e, f, g, h = self.pts 136 | edges = [ Edge(a,b,ec), Edge(b,c,ec), Edge(c,d,ec), Edge(d,a,ec) 137 | , Edge(e,f,ec), Edge(f,g,ec), Edge(g,h,ec), Edge(h,e,ec) 138 | , Edge(a,e,ec), Edge(b,f,ec), Edge(c,g,ec), Edge(d,h,ec) 139 | ] 140 | return edges 141 | 142 | def erase(self,screen): 143 | """ erase object at present rotation (last one drawn to screen) """ 144 | assert isinstance(screen,Screen) 145 | sides = self.sides() 146 | edges = self.edges() 147 | erasables = sides + edges 148 | [ s.erase(screen) for s in erasables] 149 | 150 | def draw(self,screen,q=Quaternion(1,0,0,0)): 151 | """ draw object at given rotation """ 152 | assert isinstance(screen,Screen) 153 | self.origin() 154 | self.rotate(q) 155 | sides = self.sides() 156 | edges = self.edges() 157 | drawables = sides + edges 158 | drawables.sort(key=lambda s: screen.depth(s.centroid())) 159 | [ s.draw(screen) for s in drawables ] 160 | 161 | def rotate(self,q): 162 | assert isinstance(q,Quaternion) 163 | R = q.get_matrix() 164 | self.pts = [R*p for p in self.pts] 165 | 166 | if __name__ == "__main__": 167 | pygame.init() 168 | screen = Screen(480,400,scale=1.5) 169 | cube = Cube(40,30,60) 170 | q = Quaternion(1,0,0,0) 171 | incr = Quaternion(0.96,0.01,0.01,0).normalized() 172 | 173 | while 1: 174 | q = q * incr 175 | cube.draw(screen,q) 176 | event = pygame.event.poll() 177 | if event.type == pygame.QUIT \ 178 | or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE): 179 | break 180 | pygame.display.flip() 181 | pygame.time.delay(50) 182 | cube.erase(screen) 183 | 184 | -------------------------------------------------------------------------------- /external/motion_driver_6.12/emd 6.1.2 release note.txt: -------------------------------------------------------------------------------- 1 | Changes Notes - from MD6.1 to 6.12 2 | 3 | - Fixed Hardware Calibration Offset register accel format 4 | 5 | Previous implementation was saving the offsets in the accel offset registers in a scalre range of +-8G. After clarification the format should be saved in scale range of +-16G 6 | 7 | - Fixed sometimes for 9-axis sensor fusion new data flag is not updated 8 | 9 | In hal_outputs.c, there is a flag which indicates when there is new 9-axis data to be pushed into the MPL library to be built. Flag was looking into the wrong settings to be set. 10 | 11 | - added gravity vector data output 12 | 13 | Gravity vector will give on which axis the gravity is effecting on the accel. This way you can always see where the gravity is on the device 14 | 15 | - Added ARM precompiled MPL libaries for IAR, Keil, and GCC 4.9.3 16 | 17 | Precompiled MPL libraries using IAR and Keil compiler for M0, M0+,M3, M4, M4F. GCC libraries updated to GCC 4.9.3 and there are M0, M3, and M4 with no FP, softFP, and hardFP. GCC compiler settings are based on 18 | 19 | GCC recommanded settings. You can choose which one fits best into their project. 20 | 21 | - Fixed low power motion interrupt to set the LPF accel filters correctly 22 | 23 | When going into low power motion interrupt mode, the LPF of the accel should be turned off. Previously it was not fully turned off wbecause need to set F_CHOICE bit. Now it turns off and restores correctly. 24 | 25 | - Updated Documents 26 | 27 | Updated all documents to MD6.12 28 | 29 | - Removed STM32L M3 project 30 | 31 | You shoud be able to use the M4 project and also the MPL libraries to port to other ARM MCU cores. 32 | 33 | - Misc error messaging -------------------------------------------------------------------------------- /peripheral/blinky/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup blinky_example_main main.c 16 | * @{ 17 | * @ingroup blinky_example 18 | * @brief Blinky Example Application main file. 19 | * 20 | * This file contains the source code for a sample application to blink LEDs. 21 | * 22 | */ 23 | 24 | #include 25 | #include 26 | #include "nrf_delay.h" 27 | #include "bsp.h" 28 | 29 | static const uint8_t leds_list[LEDS_NUMBER] = LEDS_LIST; 30 | 31 | /** 32 | * @brief Function for application main entry. 33 | */ 34 | int main(void) 35 | { 36 | /* Configure LED-pins as outputs. */ 37 | LEDS_CONFIGURE(LEDS_MASK); 38 | 39 | /* Toggle LEDs. */ 40 | while (true) 41 | { 42 | for (int i = 0; i < LEDS_NUMBER; i++) 43 | { 44 | LEDS_INVERT(1 << leds_list[i]); 45 | nrf_delay_ms(500); 46 | } 47 | } 48 | } 49 | 50 | /** 51 | *@} 52 | **/ 53 | -------------------------------------------------------------------------------- /peripheral/blinky/pesky/blank/armgcc/blinky_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /peripheral/blinky/pesky/s132/armgcc/blinky_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000 9 | RAM (rwx) : ORIGIN = 0x200013c8, LENGTH = 0xec38 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /peripheral/bmp280/README.md: -------------------------------------------------------------------------------- 1 | # BMP280 2 | 3 | This example shows basic usage of BMP280 with Bosch driver (https://github.com/BoschSensortec/BMP280_driver). It inits BMP280 and repetedly reads compensated pressure (x/100 hPa) and temperature (x/100 C) values. 4 | 5 | Compile, flash, open RTT Viewer and you should see repeating logs: 6 | 7 | ![bmp280](https://cloud.githubusercontent.com/assets/14309815/22763123/8a046024-ee6b-11e6-9b3c-0adea13610a5.gif) 8 | -------------------------------------------------------------------------------- /peripheral/bmp280/main.c: -------------------------------------------------------------------------------- 1 | #include "boards.h" 2 | #include "nrf_drv_rtc.h" 3 | #include "nrf_drv_clock.h" 4 | #include "bsp.h" 5 | #include "app_twi.h" 6 | #include "nrf_delay.h" 7 | #define NRF_LOG_MODULE_NAME "APP" 8 | #include "nrf_log.h" 9 | #include "nrf_log_ctrl.h" 10 | #include "bmp280.h" 11 | 12 | #define MAX_PENDING_TRANSACTIONS 8 13 | #define I2C_BUFFER_LEN 24 14 | #define BMP280_DATA_INDEX 1 15 | 16 | // Pin number for indicating communication with sensors. 17 | #ifdef BSP_LED_2 18 | #define READ_ALL_INDICATOR BSP_LED_2 19 | #else 20 | #error "Please choose an output pin" 21 | #endif 22 | 23 | static app_twi_t m_app_twi = APP_TWI_INSTANCE(0); 24 | 25 | static nrf_drv_rtc_t const m_rtc = NRF_DRV_RTC_INSTANCE(0); 26 | 27 | struct bmp280_t bmp280; 28 | 29 | static void read(void) 30 | { 31 | // Signal on LED that something is going on. 32 | nrf_gpio_pin_toggle(READ_ALL_INDICATOR); 33 | 34 | s32 com_rslt = ERROR; 35 | u32 v_actual_press_combined_u32 = BMP280_INIT_VALUE; 36 | s32 v_actual_temp_combined_s32 = BMP280_INIT_VALUE; 37 | 38 | com_rslt = bmp280_read_pressure_temperature(&v_actual_press_combined_u32, &v_actual_temp_combined_s32); 39 | APP_ERROR_CHECK(com_rslt); 40 | 41 | NRF_LOG_RAW_INFO("P, %d, T, %d\r\n", v_actual_press_combined_u32, v_actual_temp_combined_s32); 42 | } 43 | 44 | // TWI (with transaction manager) initialization. 45 | static void twi_config(void) 46 | { 47 | uint32_t err_code; 48 | 49 | nrf_drv_twi_config_t const config = { 50 | .scl = ARDUINO_SCL_PIN, 51 | .sda = ARDUINO_SDA_PIN, 52 | .frequency = NRF_TWI_FREQ_400K, 53 | .interrupt_priority = APP_IRQ_PRIORITY_LOW, 54 | .clear_bus_init = false 55 | }; 56 | 57 | APP_TWI_INIT(&m_app_twi, &config, MAX_PENDING_TRANSACTIONS, err_code); 58 | APP_ERROR_CHECK(err_code); 59 | } 60 | 61 | 62 | // RTC tick events generation. 63 | static void rtc_handler(nrf_drv_rtc_int_type_t int_type) 64 | { 65 | if (int_type == NRF_DRV_RTC_INT_TICK) 66 | { 67 | // On each RTC tick (their frequency is set in "nrf_drv_config.h") 68 | // we read data from our sensor. 69 | read(); 70 | } 71 | } 72 | static void rtc_config(void) 73 | { 74 | uint32_t err_code; 75 | 76 | // Initialize RTC instance with default configuration. 77 | nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG; 78 | config.prescaler = RTC_FREQ_TO_PRESCALER(27); 79 | err_code = nrf_drv_rtc_init(&m_rtc, &config, rtc_handler); 80 | APP_ERROR_CHECK(err_code); 81 | 82 | // Enable tick event and interrupt. 83 | nrf_drv_rtc_tick_enable(&m_rtc, true); 84 | 85 | // Power on RTC instance. 86 | nrf_drv_rtc_enable(&m_rtc); 87 | } 88 | 89 | 90 | static void lfclk_config(void) 91 | { 92 | uint32_t err_code; 93 | 94 | err_code = nrf_drv_clock_init(); 95 | APP_ERROR_CHECK(err_code); 96 | 97 | nrf_drv_clock_lfclk_request(NULL); 98 | } 99 | 100 | s8 BMP280_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt) 101 | { 102 | s32 iError = BMP280_INIT_VALUE; 103 | u8 array[I2C_BUFFER_LEN]; 104 | u8 stringpos = BMP280_INIT_VALUE; 105 | array[BMP280_INIT_VALUE] = reg_addr; 106 | for (stringpos = BMP280_INIT_VALUE; stringpos < cnt; stringpos++) { 107 | array[stringpos + BMP280_DATA_INDEX] = *(reg_data + stringpos); 108 | } 109 | 110 | app_twi_transfer_t const transfers[] = 111 | { 112 | APP_TWI_WRITE(dev_addr, array, cnt + 1, 0) 113 | }; 114 | 115 | iError = app_twi_perform(&m_app_twi, transfers, sizeof(transfers) / sizeof(transfers[0]), NULL); 116 | //APP_ERROR_CHECK(err_code); 117 | // if (reg_addr < 0xF7) { 118 | // NRF_LOG_INFO("W %X %X %X %X\r\n", dev_addr, reg_addr, cnt, iError); 119 | // NRF_LOG_HEXDUMP_INFO(reg_data, cnt); 120 | // //NRF_LOG_FLUSH(); 121 | // } 122 | 123 | return (s8)iError; 124 | } 125 | 126 | s8 BMP280_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt) 127 | { 128 | s32 iError = BMP280_INIT_VALUE; 129 | u8 array[I2C_BUFFER_LEN] = {BMP280_INIT_VALUE}; 130 | u8 stringpos = BMP280_INIT_VALUE; 131 | array[BMP280_INIT_VALUE] = reg_addr; 132 | 133 | app_twi_transfer_t const transfers[] = 134 | { 135 | APP_TWI_WRITE(dev_addr, ®_addr, 1, APP_TWI_NO_STOP), 136 | APP_TWI_READ (dev_addr, array, cnt, 0) 137 | }; 138 | 139 | iError = app_twi_perform(&m_app_twi, transfers, sizeof(transfers) / sizeof(transfers[0]), NULL); 140 | //APP_ERROR_CHECK(err_code); 141 | // if (reg_addr < 0xF7) { 142 | // NRF_LOG_INFO("R %X %X %X %X\r\n", dev_addr, reg_addr, cnt, iError); 143 | // NRF_LOG_HEXDUMP_INFO(array, cnt); 144 | // //NRF_LOG_FLUSH(); 145 | // } 146 | 147 | for (stringpos = BMP280_INIT_VALUE; stringpos < cnt; stringpos++) { 148 | *(reg_data + stringpos) = array[stringpos]; 149 | } 150 | 151 | return (s8)iError; 152 | } 153 | 154 | void BMP280_delay_msek(u32 msek) 155 | { 156 | nrf_delay_ms(msek); 157 | } 158 | 159 | static void bmp280_config(void) 160 | { 161 | bmp280.bus_write = BMP280_I2C_bus_write; 162 | bmp280.bus_read = BMP280_I2C_bus_read; 163 | bmp280.dev_addr = BMP280_I2C_ADDRESS2; 164 | bmp280.delay_msec = BMP280_delay_msek; 165 | 166 | s32 com_rslt = ERROR; 167 | com_rslt = bmp280_init(&bmp280); 168 | com_rslt += bmp280_set_power_mode(BMP280_SLEEP_MODE); 169 | com_rslt += bmp280_set_work_mode(BMP280_ULTRA_HIGH_RESOLUTION_MODE); 170 | com_rslt += bmp280_set_filter(BMP280_FILTER_COEFF_16); 171 | com_rslt += bmp280_set_standby_durn(BMP280_STANDBY_TIME_1_MS); 172 | com_rslt += bmp280_set_power_mode(BMP280_NORMAL_MODE); 173 | APP_ERROR_CHECK(com_rslt); 174 | 175 | // u8 data[4]; 176 | // bmp280.bus_read(bmp280.dev_addr, 0xF2, data, 4); 177 | // NRF_LOG_INFO("Configuration:\r\n"); 178 | // NRF_LOG_HEXDUMP_INFO(data, 4); 179 | // NRF_LOG_FLUSH(); 180 | } 181 | 182 | int main(void) 183 | { 184 | LEDS_CONFIGURE(1U << READ_ALL_INDICATOR); 185 | LEDS_OFF(1U << READ_ALL_INDICATOR); 186 | 187 | // Start internal LFCLK XTAL oscillator - it is needed 188 | // for "read" ticks generation 189 | // (by RTC). 190 | lfclk_config(); 191 | 192 | APP_ERROR_CHECK(NRF_LOG_INIT(NULL)); 193 | 194 | NRF_LOG_INFO("BMP280 example\r\n"); 195 | twi_config(); 196 | bmp280_config(); 197 | rtc_config(); 198 | 199 | while (true) 200 | { 201 | __WFI(); 202 | NRF_LOG_FLUSH(); 203 | } 204 | } 205 | 206 | 207 | /** @} */ 208 | -------------------------------------------------------------------------------- /peripheral/bmp280/pesky/blank/armgcc/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME := bmp280_pesky 2 | TARGETS := nrf52832_xxaa 3 | OUTPUT_DIRECTORY := _build 4 | 5 | SDK_ROOT := ../../../../../.. 6 | PROJ_DIR := ../../.. 7 | 8 | $(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \ 9 | LINKER_SCRIPT := bmp280_gcc_nrf52.ld 10 | # Source files common to all targets 11 | SRC_FILES += \ 12 | $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \ 13 | $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \ 14 | $(SDK_ROOT)/components/libraries/button/app_button.c \ 15 | $(SDK_ROOT)/components/libraries/util/app_error.c \ 16 | $(SDK_ROOT)/components/libraries/util/app_error_weak.c \ 17 | $(SDK_ROOT)/components/libraries/timer/app_timer.c \ 18 | $(SDK_ROOT)/components/libraries/twi/app_twi.c \ 19 | $(SDK_ROOT)/components/libraries/util/app_util_platform.c \ 20 | $(SDK_ROOT)/components/libraries/util/nrf_assert.c \ 21 | $(SDK_ROOT)/components/drivers_nrf/clock/nrf_drv_clock.c \ 22 | $(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \ 23 | $(SDK_ROOT)/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \ 24 | $(SDK_ROOT)/components/drivers_nrf/rtc/nrf_drv_rtc.c \ 25 | $(SDK_ROOT)/components/drivers_nrf/twi_master/nrf_drv_twi.c \ 26 | $(SDK_ROOT)/components/drivers_nrf/uart/nrf_drv_uart.c \ 27 | $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c \ 28 | $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c \ 29 | $(PROJ_DIR)/../../../examples/bsp/bsp.c \ 30 | $(PROJ_DIR)/main.c \ 31 | $(PROJ_DIR)/../../external/BMP280_driver/bmp280.c \ 32 | $(SDK_ROOT)/external/segger_rtt/RTT_Syscalls_GCC.c \ 33 | $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \ 34 | $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \ 35 | $(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf52.S \ 36 | $(SDK_ROOT)/components/toolchain/system_nrf52.c \ 37 | 38 | # Include folders common to all targets 39 | INC_FOLDERS += \ 40 | $(PROJ_DIR)/config/bmp280_pesky \ 41 | $(PROJ_DIR)/config \ 42 | $(SDK_ROOT)/components \ 43 | ../config \ 44 | $(PROJ_DIR) \ 45 | $(PROJ_DIR)/../../common \ 46 | $(PROJ_DIR)/../../external/BMP280_driver \ 47 | $(SDK_ROOT)/examples/bsp \ 48 | $(SDK_ROOT)/components/drivers_nrf/delay \ 49 | $(SDK_ROOT)/components/toolchain/cmsis/include \ 50 | $(SDK_ROOT)/components/libraries/util \ 51 | $(SDK_ROOT)/components/drivers_nrf/uart \ 52 | $(SDK_ROOT)/components/device \ 53 | $(SDK_ROOT)/components/libraries/log \ 54 | $(SDK_ROOT)/components/libraries/button \ 55 | $(SDK_ROOT)/components/libraries/timer \ 56 | $(SDK_ROOT)/components/drivers_nrf/twi_master \ 57 | $(SDK_ROOT)/components/drivers_nrf/gpiote \ 58 | $(SDK_ROOT)/external/segger_rtt \ 59 | $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \ 60 | $(SDK_ROOT)/components/toolchain \ 61 | $(SDK_ROOT)/components/drivers_nrf/hal \ 62 | $(SDK_ROOT)/components/toolchain/gcc \ 63 | $(SDK_ROOT)/components/drivers_nrf/rtc \ 64 | $(SDK_ROOT)/components/drivers_nrf/common \ 65 | $(SDK_ROOT)/components/libraries/twi \ 66 | $(SDK_ROOT)/components/drivers_nrf/clock \ 67 | $(SDK_ROOT)/components/libraries/log/src \ 68 | 69 | # Libraries common to all targets 70 | LIB_FILES += \ 71 | 72 | # C flags common to all targets 73 | CFLAGS += -DNRF52_PAN_12 74 | CFLAGS += -DNRF52_PAN_15 75 | CFLAGS += -DNRF52_PAN_58 76 | CFLAGS += -DSWI_DISABLE0 77 | CFLAGS += -DNRF52_PAN_20 78 | CFLAGS += -DNRF52_PAN_54 79 | CFLAGS += -DNRF52_PAN_31 80 | CFLAGS += -DNRF52_PAN_30 81 | CFLAGS += -DNRF52_PAN_51 82 | CFLAGS += -DNRF52_PAN_36 83 | CFLAGS += -DNRF52_PAN_53 84 | CFLAGS += -DCONFIG_GPIO_AS_PINRESET 85 | CFLAGS += -DNRF52_PAN_64 86 | CFLAGS += -DNRF52_PAN_55 87 | CFLAGS += -DNRF52_PAN_62 88 | CFLAGS += -DNRF52_PAN_63 89 | CFLAGS += -DBOARD_CUSTOM 90 | CFLAGS += -DNRF52 91 | CFLAGS += -DNRF52832 92 | CFLAGS += -mcpu=cortex-m4 93 | CFLAGS += -mthumb -mabi=aapcs 94 | CFLAGS += -Wall -Werror -O3 -g3 95 | CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 96 | # keep every function in separate section, this allows linker to discard unused ones 97 | CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing 98 | CFLAGS += -fno-builtin --short-enums 99 | # generate dependency output file 100 | CFLAGS += -MP -MD 101 | 102 | # C++ flags common to all targets 103 | CXXFLAGS += \ 104 | 105 | # Assembler flags common to all targets 106 | ASMFLAGS += -x assembler-with-cpp 107 | ASMFLAGS += -DNRF52_PAN_12 108 | ASMFLAGS += -DNRF52_PAN_15 109 | ASMFLAGS += -DNRF52_PAN_58 110 | ASMFLAGS += -DSWI_DISABLE0 111 | ASMFLAGS += -DNRF52_PAN_20 112 | ASMFLAGS += -DNRF52_PAN_54 113 | ASMFLAGS += -DNRF52_PAN_31 114 | ASMFLAGS += -DNRF52_PAN_30 115 | ASMFLAGS += -DNRF52_PAN_51 116 | ASMFLAGS += -DNRF52_PAN_36 117 | ASMFLAGS += -DNRF52_PAN_53 118 | ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET 119 | ASMFLAGS += -DNRF52_PAN_64 120 | ASMFLAGS += -DNRF52_PAN_55 121 | ASMFLAGS += -DNRF52_PAN_62 122 | ASMFLAGS += -DNRF52_PAN_63 123 | ASMFLAGS += -DBOARD_CUSTOM 124 | ASMFLAGS += -DNRF52 125 | ASMFLAGS += -DNRF52832 126 | 127 | # Linker flags 128 | LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT) 129 | LDFLAGS += -mcpu=cortex-m4 130 | LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 131 | # let linker to dump unused sections 132 | LDFLAGS += -Wl,--gc-sections 133 | # use newlib in nano version 134 | LDFLAGS += --specs=nano.specs -lc -lnosys 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | .PHONY: $(TARGETS) default all clean help flash 143 | # Default target - first one defined 144 | default: nrf52832_xxaa 145 | 146 | # Print all targets that can be built 147 | help: 148 | @echo following targets are available: 149 | @echo nrf52832_xxaa 150 | 151 | TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc 152 | 153 | include $(TEMPLATE_PATH)/Makefile.common 154 | $(foreach target, $(TARGETS), $(call define_target, $(target))) 155 | -include $(foreach target, $(TARGETS), $($(target)_dependencies)) 156 | 157 | # Flash the program 158 | flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex 159 | @echo Flashing: $< 160 | nrfjprog --program $< -f nrf52 --chiperase 161 | nrfjprog --reset -f nrf52 162 | 163 | -------------------------------------------------------------------------------- /peripheral/bmp280/pesky/blank/armgcc/bmp280_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /peripheral/md612/README.md: -------------------------------------------------------------------------------- 1 | # Invensense Motion Driver 6.12 Example 2 | 3 | ![md612 2](https://cloud.githubusercontent.com/assets/14309815/22778555/0aaaa32e-eec0-11e6-9c70-5df3dec03579.gif) 4 | 5 | It is an adaptation of example from Motion Driver SDK from Invensense. 6 | It uses COM port to send data to PC, and on PC you should do: 7 | 8 | python projects\external\motion_driver_6.12\eMPL-pythonclient\eMPL-client.py COM6 9 | 10 | Where instead of COM6 put your COM port number. Example were tested on Python 2.7.11 from Anaconda 4.0.0 package. 11 | It could ask you to install pyserial, pygame via pip. 12 | 13 | These commands turn off individual sensors: 14 | - 8 - toggle accelerometer on/off 15 | - 9 - toggle gyroscope on/off 16 | - 0 - toggle compass on/off 17 | 18 | These commands send individual sensor data or fused data to the PC: 19 | - a - accelerometer 20 | - g - gyroscope 21 | - c - compass 22 | - e - Euler angles 23 | - r - rotation matrix 24 | - q - quaternion 25 | - i - linear acceleration vector 26 | - o - gravity vector 27 | 28 | Other commands: 29 | - w - prints status of the compass (?) 30 | - f - toggle DMP 31 | - m - test motion interrupt hardware feature 32 | - x - reset board 33 | - v - toggle 6x LP quaternion 34 | - d - if logging enabled, it dumps all registers 35 | - p - if DMP disabled - turns on **low power accel. mode** 36 | - t - run self test 37 | - , - set HW INT to gesture mode only 38 | - . - set HW INT to continuous mode 39 | - 1-5 - changes data rate from gyro and accell 40 | - 6 - toggle pedometer display 41 | - 7 - reset pedometer 42 | 43 | Custom commands (not available in original implementation): 44 | - b - print biases and calibration data 45 | 46 | Note that when running python application, it will not react on keypresses when console window in focus. 47 | You should focus 3D window and then keypresses will work. 48 | -------------------------------------------------------------------------------- /peripheral/md612/pesky/blank/armgcc/md612_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /peripheral/mpu9250/README.md: -------------------------------------------------------------------------------- 1 | # MPU9250 2 | 3 | This example shows basic usage of MPU9250 with Invensense SDK (Motion Driver 6.12). It inits MPU9250, inits DMP, inits DMP data-ready interrupt and repetedly reads 6x low-power quaternion. 4 | 5 | In **core** folder you can find adapted version of MD, which you can compare against **core_orig** for changes. 6 | Also **inv_pesky.h** contains ported functions required by MD. 7 | 8 | Compile, flash, open RTT Viewer and you should see repeating logs: 9 | 10 | ![image](https://cloud.githubusercontent.com/assets/14309815/18893064/ee61033a-8514-11e6-9834-d1f75523fc70.png) 11 | 12 | 30.01.2017: log format were updated to make it easer export to CSV and analysis so it slightly different than shown on the video above. -------------------------------------------------------------------------------- /peripheral/mpu9250/pesky/blank/armgcc/mpu9250_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /peripheral/pin_change_int/README.md: -------------------------------------------------------------------------------- 1 | # Interrupts 2 | 3 | This example shows basic usage of interrupts (adapted from example from official SDK). 4 | It removes protection from pins 9, 10 (used as NFC1,2 by default) so that you can use them as ordinary GPIO. 5 | Interrupt configured on pin 9 to toggle led on pin 22. So if you connect pin 9 to GND led will toggle. 6 | 7 | Compile, flash, play with pin 9 and you should see something like that: 8 | 9 | ![image](https://cloud.githubusercontent.com/assets/14309815/18880402/679c1bd4-84e0-11e6-8744-2b15b10cffab.gif) -------------------------------------------------------------------------------- /peripheral/pin_change_int/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * @defgroup pin_change_int_example_main main.c 15 | * @{ 16 | * @ingroup pin_change_int_example 17 | * @brief Pin Change Interrupt Example Application main file. 18 | * 19 | * This file contains the source code for a sample application using interrupts triggered by GPIO pins. 20 | * 21 | */ 22 | 23 | #include 24 | #include "nrf.h" 25 | #include "nrf_drv_gpiote.h" 26 | #include "app_error.h" 27 | #include "boards.h" 28 | 29 | #ifdef BSP_BUTTON_1 30 | #define PIN_IN BSP_BUTTON_1 // Pin 9 used as NFC0 by default and protected from being used as GPIO. Call remove_nfc_protection() function below to use it as GPIO. 31 | #endif 32 | #ifndef PIN_IN 33 | #error "Please indicate input pin" 34 | #endif 35 | 36 | #ifdef BSP_LED_0 37 | #define PIN_OUT BSP_LED_0 38 | #endif 39 | #ifndef PIN_OUT 40 | #error "Please indicate output pin" 41 | #endif 42 | 43 | void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) 44 | { 45 | nrf_drv_gpiote_out_toggle(PIN_OUT); 46 | } 47 | /** 48 | * @brief Function for configuring: PIN_IN pin for input, PIN_OUT pin for output, 49 | * and configures GPIOTE to give an interrupt on pin change. 50 | */ 51 | static void gpio_init(void) 52 | { 53 | ret_code_t err_code; 54 | 55 | err_code = nrf_drv_gpiote_init(); 56 | APP_ERROR_CHECK(err_code); 57 | 58 | nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false); 59 | 60 | err_code = nrf_drv_gpiote_out_init(PIN_OUT, &out_config); 61 | APP_ERROR_CHECK(err_code); 62 | 63 | nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true); 64 | in_config.pull = NRF_GPIO_PIN_PULLUP; 65 | 66 | err_code = nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler); 67 | APP_ERROR_CHECK(err_code); 68 | 69 | nrf_drv_gpiote_in_event_enable(PIN_IN, true); 70 | } 71 | 72 | /** 73 | * @brief Function for application main entry. 74 | */ 75 | int main(void) 76 | { 77 | gpio_init(); 78 | 79 | while (true) 80 | { 81 | // Do nothing. 82 | } 83 | } 84 | 85 | 86 | /** @} */ 87 | -------------------------------------------------------------------------------- /peripheral/pin_change_int/pesky/blank/armgcc/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME := pin_change_int_pesky 2 | TARGETS := nrf52832_xxaa 3 | OUTPUT_DIRECTORY := _build 4 | 5 | SDK_ROOT := ../../../../../.. 6 | PROJ_DIR := ../../.. 7 | 8 | $(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \ 9 | LINKER_SCRIPT := pin_change_int_gcc_nrf52.ld 10 | # Source files common to all targets 11 | SRC_FILES += \ 12 | $(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf52.S \ 13 | $(SDK_ROOT)/components/toolchain/system_nrf52.c \ 14 | $(PROJ_DIR)/main.c \ 15 | $(SDK_ROOT)/components/libraries/util/app_error.c \ 16 | $(SDK_ROOT)/components/libraries/util/app_error_weak.c \ 17 | $(SDK_ROOT)/components/libraries/util/nrf_assert.c \ 18 | $(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \ 19 | $(SDK_ROOT)/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \ 20 | 21 | # Include folders common to all targets 22 | INC_FOLDERS += \ 23 | $(PROJ_DIR)/config/pin_change_int_pesky \ 24 | $(PROJ_DIR)/config \ 25 | $(SDK_ROOT)/components \ 26 | $(SDK_ROOT)/components/libraries/util \ 27 | $(SDK_ROOT)/components/toolchain/gcc \ 28 | $(SDK_ROOT)/components/toolchain \ 29 | $(SDK_ROOT)/components/drivers_nrf/common \ 30 | $(PROJ_DIR) \ 31 | $(SDK_ROOT)/components/drivers_nrf/gpiote \ 32 | $(PROJ_DIR)/../../common \ 33 | $(SDK_ROOT)/examples/bsp \ 34 | $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \ 35 | ../config \ 36 | $(SDK_ROOT)/components/device \ 37 | $(SDK_ROOT)/components/libraries/log \ 38 | $(SDK_ROOT)/components/toolchain/cmsis/include \ 39 | $(SDK_ROOT)/components/drivers_nrf/hal \ 40 | $(SDK_ROOT)/components/libraries/log/src \ 41 | 42 | # Libraries common to all targets 43 | LIB_FILES += \ 44 | 45 | # C flags common to all targets 46 | CFLAGS += -DNRF52_PAN_12 47 | CFLAGS += -DNRF52_PAN_15 48 | CFLAGS += -DNRF52_PAN_58 49 | CFLAGS += -DNRF52_PAN_20 50 | CFLAGS += -DNRF52_PAN_54 51 | CFLAGS += -DNRF52_PAN_31 52 | CFLAGS += -DNRF52_PAN_30 53 | CFLAGS += -DNRF52_PAN_51 54 | CFLAGS += -DNRF52_PAN_36 55 | CFLAGS += -DNRF52_PAN_53 56 | CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS 57 | CFLAGS += -DNRF52_PAN_64 58 | CFLAGS += -DNRF52_PAN_55 59 | CFLAGS += -DNRF52_PAN_62 60 | CFLAGS += -DNRF52_PAN_63 61 | CFLAGS += -DBOARD_CUSTOM 62 | CFLAGS += -DNRF52 63 | CFLAGS += -DNRF52832 64 | CFLAGS += -DBSP_DEFINES_ONLY 65 | CFLAGS += -mcpu=cortex-m4 66 | CFLAGS += -mthumb -mabi=aapcs 67 | CFLAGS += -Wall -Werror -O3 -g3 68 | CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 69 | # keep every function in separate section, this allows linker to discard unused ones 70 | CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing 71 | CFLAGS += -fno-builtin --short-enums 72 | # generate dependency output file 73 | CFLAGS += -MP -MD 74 | 75 | # C++ flags common to all targets 76 | CXXFLAGS += \ 77 | 78 | # Assembler flags common to all targets 79 | ASMFLAGS += -x assembler-with-cpp 80 | ASMFLAGS += -DNRF52_PAN_12 81 | ASMFLAGS += -DNRF52_PAN_15 82 | ASMFLAGS += -DNRF52_PAN_58 83 | ASMFLAGS += -DNRF52_PAN_20 84 | ASMFLAGS += -DNRF52_PAN_54 85 | ASMFLAGS += -DNRF52_PAN_31 86 | ASMFLAGS += -DNRF52_PAN_30 87 | ASMFLAGS += -DNRF52_PAN_51 88 | ASMFLAGS += -DNRF52_PAN_36 89 | ASMFLAGS += -DNRF52_PAN_53 90 | ASMFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS 91 | ASMFLAGS += -DNRF52_PAN_64 92 | ASMFLAGS += -DNRF52_PAN_55 93 | ASMFLAGS += -DNRF52_PAN_62 94 | ASMFLAGS += -DNRF52_PAN_63 95 | ASMFLAGS += -DBOARD_CUSTOM 96 | ASMFLAGS += -DNRF52 97 | ASMFLAGS += -DNRF52832 98 | ASMFLAGS += -DBSP_DEFINES_ONLY 99 | 100 | # Linker flags 101 | LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT) 102 | LDFLAGS += -mcpu=cortex-m4 103 | LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 104 | # let linker to dump unused sections 105 | LDFLAGS += -Wl,--gc-sections 106 | # use newlib in nano version 107 | LDFLAGS += --specs=nano.specs -lc -lnosys 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | .PHONY: $(TARGETS) default all clean help flash 116 | # Default target - first one defined 117 | default: nrf52832_xxaa 118 | 119 | # Print all targets that can be built 120 | help: 121 | @echo following targets are available: 122 | @echo nrf52832_xxaa 123 | 124 | TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc 125 | 126 | include $(TEMPLATE_PATH)/Makefile.common 127 | $(foreach target, $(TARGETS), $(call define_target, $(target))) 128 | -include $(foreach target, $(TARGETS), $($(target)_dependencies)) 129 | 130 | # Flash the program 131 | flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex 132 | @echo Flashing: $< 133 | nrfjprog --program $< -f nrf52 --chiperase 134 | nrfjprog --reset -f nrf52 135 | 136 | -------------------------------------------------------------------------------- /peripheral/pin_change_int/pesky/blank/armgcc/pin_change_int_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /peripheral/pin_change_int/pesky/blank/config/sdk_config.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef SDK_CONFIG_H 4 | #define SDK_CONFIG_H 5 | // <<< Use Configuration Wizard in Context Menu >>>\n 6 | #ifdef USE_APP_CONFIG 7 | #include "app_config.h" 8 | #endif 9 | // nRF_Drivers 10 | 11 | //========================================================== 12 | // GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver 13 | //========================================================== 14 | #ifndef GPIOTE_ENABLED 15 | #define GPIOTE_ENABLED 1 16 | #endif 17 | #if GPIOTE_ENABLED 18 | // GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins 19 | #ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 20 | #define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 21 | #endif 22 | 23 | // GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority 24 | 25 | 26 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 27 | // <0=> 0 (highest) 28 | // <1=> 1 29 | // <2=> 2 30 | // <3=> 3 31 | // <4=> 4 32 | // <5=> 5 33 | // <6=> 6 34 | // <7=> 7 35 | 36 | #ifndef GPIOTE_CONFIG_IRQ_PRIORITY 37 | #define GPIOTE_CONFIG_IRQ_PRIORITY 6 38 | #endif 39 | 40 | #endif //GPIOTE_ENABLED 41 | // 42 | 43 | // PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module 44 | 45 | 46 | #ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED 47 | #define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 48 | #endif 49 | 50 | // 51 | //========================================================== 52 | 53 | // nRF_Log 54 | 55 | //========================================================== 56 | // NRF_LOG_ENABLED - nrf_log - Logging 57 | //========================================================== 58 | #ifndef NRF_LOG_ENABLED 59 | #define NRF_LOG_ENABLED 0 60 | #endif 61 | #if NRF_LOG_ENABLED 62 | // NRF_LOG_USES_COLORS - If enabled then ANSI escape code for colors is prefixed to every string 63 | //========================================================== 64 | #ifndef NRF_LOG_USES_COLORS 65 | #define NRF_LOG_USES_COLORS 0 66 | #endif 67 | #if NRF_LOG_USES_COLORS 68 | // NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. 69 | 70 | // <0=> Default 71 | // <1=> Black 72 | // <2=> Red 73 | // <3=> Green 74 | // <4=> Yellow 75 | // <5=> Blue 76 | // <6=> Magenta 77 | // <7=> Cyan 78 | // <8=> White 79 | 80 | #ifndef NRF_LOG_COLOR_DEFAULT 81 | #define NRF_LOG_COLOR_DEFAULT 0 82 | #endif 83 | 84 | // NRF_LOG_ERROR_COLOR - ANSI escape code prefix. 85 | 86 | // <0=> Default 87 | // <1=> Black 88 | // <2=> Red 89 | // <3=> Green 90 | // <4=> Yellow 91 | // <5=> Blue 92 | // <6=> Magenta 93 | // <7=> Cyan 94 | // <8=> White 95 | 96 | #ifndef NRF_LOG_ERROR_COLOR 97 | #define NRF_LOG_ERROR_COLOR 0 98 | #endif 99 | 100 | // NRF_LOG_WARNING_COLOR - ANSI escape code prefix. 101 | 102 | // <0=> Default 103 | // <1=> Black 104 | // <2=> Red 105 | // <3=> Green 106 | // <4=> Yellow 107 | // <5=> Blue 108 | // <6=> Magenta 109 | // <7=> Cyan 110 | // <8=> White 111 | 112 | #ifndef NRF_LOG_WARNING_COLOR 113 | #define NRF_LOG_WARNING_COLOR 0 114 | #endif 115 | 116 | #endif //NRF_LOG_USES_COLORS 117 | // 118 | 119 | // NRF_LOG_DEFAULT_LEVEL - Default Severity level 120 | 121 | // <0=> Off 122 | // <1=> Error 123 | // <2=> Warning 124 | // <3=> Info 125 | // <4=> Debug 126 | 127 | #ifndef NRF_LOG_DEFAULT_LEVEL 128 | #define NRF_LOG_DEFAULT_LEVEL 3 129 | #endif 130 | 131 | // NRF_LOG_DEFERRED - Enable deffered logger. 132 | 133 | // Log data is buffered and can be processed in idle. 134 | //========================================================== 135 | #ifndef NRF_LOG_DEFERRED 136 | #define NRF_LOG_DEFERRED 1 137 | #endif 138 | #if NRF_LOG_DEFERRED 139 | // NRF_LOG_DEFERRED_BUFSIZE - Size of the buffer for logs in words. 140 | // Must be power of 2 141 | 142 | #ifndef NRF_LOG_DEFERRED_BUFSIZE 143 | #define NRF_LOG_DEFERRED_BUFSIZE 256 144 | #endif 145 | 146 | #endif //NRF_LOG_DEFERRED 147 | // 148 | 149 | // NRF_LOG_USES_TIMESTAMP - Enable timestamping 150 | 151 | 152 | // Function for getting the timestamp is provided by the user 153 | 154 | #ifndef NRF_LOG_USES_TIMESTAMP 155 | #define NRF_LOG_USES_TIMESTAMP 0 156 | #endif 157 | 158 | #endif //NRF_LOG_ENABLED 159 | // 160 | 161 | // 162 | //========================================================== 163 | 164 | // <<< end of configuration section >>> 165 | #endif //SDK_CONFIG_H 166 | 167 | -------------------------------------------------------------------------------- /peripheral/twi_master_using_app_twi/README.md: -------------------------------------------------------------------------------- 1 | # TWI 2 | 3 | This example shows basic usage of TWI and RTC (adapted from example from official SDK). It inits MPU9250 and repeatedly reads WHO_AM_I register value. 4 | 5 | Compile, flash, open RTT Viewer and you should see repeating logs: 6 | 7 | ![image](https://cloud.githubusercontent.com/assets/14309815/18491178/d9465840-7a0d-11e6-83b4-31be814a0e01.png) 8 | -------------------------------------------------------------------------------- /peripheral/twi_master_using_app_twi/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * @defgroup nrf_twi_master_example main.c 15 | * @{ 16 | * @ingroup nrf_twi_example 17 | * @brief TWI Example Application main file. 18 | * 19 | * This file contains the source code for a sample application using TWI. 20 | */ 21 | 22 | #include "boards.h" 23 | #include "nrf_drv_rtc.h" 24 | #include "nrf_drv_clock.h" 25 | #include "bsp.h" 26 | #include "app_twi.h" 27 | #include "nrf_delay.h" 28 | #define NRF_LOG_MODULE_NAME "APP" 29 | #include "nrf_log.h" 30 | #include "nrf_log_ctrl.h" 31 | 32 | 33 | #define MAX_PENDING_TRANSACTIONS 5 34 | 35 | #define MPU_PWR_MGMT_1_REG 0x6B 36 | #define MPU_WHO_AM_I_REG 0x75 37 | #define MPU_I2C_ADDRESS 0x68 38 | #define BIT_RESET 0x80 39 | 40 | // Pin number for indicating communication with sensors. 41 | #ifdef BSP_LED_2 42 | #define READ_ALL_INDICATOR BSP_LED_2 43 | #else 44 | #error "Please choose an output pin" 45 | #endif 46 | 47 | 48 | static app_twi_t m_app_twi = APP_TWI_INSTANCE(0); 49 | 50 | static nrf_drv_rtc_t const m_rtc = NRF_DRV_RTC_INSTANCE(0); 51 | 52 | 53 | uint8_t const mpu_who_am_i_reg_addr = MPU_WHO_AM_I_REG; 54 | 55 | #define BUFFER_SIZE 5 56 | static uint8_t m_buffer[BUFFER_SIZE] = { MPU_PWR_MGMT_1_REG, BIT_RESET, MPU_PWR_MGMT_1_REG, 0x00, 0x00 }; 57 | 58 | static app_twi_transfer_t const mpu_init_transfers[] = 59 | { 60 | APP_TWI_WRITE(MPU_I2C_ADDRESS, &m_buffer[0], 2, 0), 61 | APP_TWI_WRITE(MPU_I2C_ADDRESS, &m_buffer[2], 2, 0), 62 | }; 63 | 64 | void read_cb(ret_code_t result, void * p_user_data) 65 | { 66 | if (result != NRF_SUCCESS) 67 | { 68 | NRF_LOG_INFO("read_cb - error: %d\r\n", (int)result); 69 | return; 70 | } 71 | 72 | uint8_t whoami = m_buffer[4]; 73 | NRF_LOG_INFO("WHOAMI: %d\r\n", (int)whoami); 74 | } 75 | 76 | static void read(void) 77 | { 78 | 79 | // Signal on LED that something is going on. 80 | nrf_gpio_pin_toggle(READ_ALL_INDICATOR); 81 | 82 | // [these structures have to be "static" - they cannot be placed on stack 83 | // since the transaction is scheduled and these structures most likely 84 | // will be referred after this function returns] 85 | static app_twi_transfer_t const transfers[] = 86 | { 87 | APP_TWI_WRITE(MPU_I2C_ADDRESS, &mpu_who_am_i_reg_addr, 1, APP_TWI_NO_STOP) 88 | , 89 | APP_TWI_READ (MPU_I2C_ADDRESS, &m_buffer[4], 1, 0) 90 | }; 91 | static app_twi_transaction_t const transaction = 92 | { 93 | .callback = read_cb, 94 | .p_user_data = NULL, 95 | .p_transfers = transfers, 96 | .number_of_transfers = sizeof(transfers) / sizeof(transfers[0]) 97 | }; 98 | 99 | APP_ERROR_CHECK(app_twi_schedule(&m_app_twi, &transaction)); 100 | } 101 | 102 | // TWI (with transaction manager) initialization. 103 | static void twi_config(void) 104 | { 105 | uint32_t err_code; 106 | 107 | nrf_drv_twi_config_t const config = { 108 | .scl = ARDUINO_SCL_PIN, 109 | .sda = ARDUINO_SDA_PIN, 110 | .frequency = NRF_TWI_FREQ_100K, 111 | .interrupt_priority = APP_IRQ_PRIORITY_LOW, 112 | .clear_bus_init = false 113 | }; 114 | 115 | APP_TWI_INIT(&m_app_twi, &config, MAX_PENDING_TRANSACTIONS, err_code); 116 | APP_ERROR_CHECK(err_code); 117 | } 118 | 119 | 120 | // RTC tick events generation. 121 | static void rtc_handler(nrf_drv_rtc_int_type_t int_type) 122 | { 123 | if (int_type == NRF_DRV_RTC_INT_TICK) 124 | { 125 | // On each RTC tick (their frequency is set in "nrf_drv_config.h") 126 | // we read data from our sensor. 127 | read(); 128 | } 129 | } 130 | static void rtc_config(void) 131 | { 132 | uint32_t err_code; 133 | 134 | // Initialize RTC instance with default configuration. 135 | nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG; 136 | config.prescaler = RTC_FREQ_TO_PRESCALER(32); //Set RTC frequency to 32Hz 137 | err_code = nrf_drv_rtc_init(&m_rtc, &config, rtc_handler); 138 | APP_ERROR_CHECK(err_code); 139 | 140 | // Enable tick event and interrupt. 141 | nrf_drv_rtc_tick_enable(&m_rtc, true); 142 | 143 | // Power on RTC instance. 144 | nrf_drv_rtc_enable(&m_rtc); 145 | } 146 | 147 | 148 | static void lfclk_config(void) 149 | { 150 | uint32_t err_code; 151 | 152 | err_code = nrf_drv_clock_init(); 153 | APP_ERROR_CHECK(err_code); 154 | 155 | nrf_drv_clock_lfclk_request(NULL); 156 | } 157 | 158 | 159 | int main(void) 160 | { 161 | LEDS_CONFIGURE(1U << READ_ALL_INDICATOR); 162 | LEDS_OFF(1U << READ_ALL_INDICATOR); 163 | 164 | // Start internal LFCLK XTAL oscillator - it is needed 165 | // for "read" ticks generation 166 | // (by RTC). 167 | lfclk_config(); 168 | 169 | APP_ERROR_CHECK(NRF_LOG_INIT(NULL)); 170 | 171 | NRF_LOG_INFO("TWI master example\r\n"); 172 | NRF_LOG_FLUSH(); 173 | twi_config(); 174 | 175 | // Initialize sensors. 176 | APP_ERROR_CHECK(app_twi_perform(&m_app_twi, &mpu_init_transfers[0], 1, NULL)); 177 | nrf_delay_ms(100); 178 | APP_ERROR_CHECK(app_twi_perform(&m_app_twi, &mpu_init_transfers[1], 1, NULL)); 179 | 180 | rtc_config(); 181 | 182 | while (true) 183 | { 184 | __WFI(); 185 | NRF_LOG_FLUSH(); 186 | } 187 | } 188 | 189 | 190 | /** @} */ 191 | -------------------------------------------------------------------------------- /peripheral/twi_master_using_app_twi/pesky/blank/armgcc/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME := twi_master_using_app_twi_pesky 2 | TARGETS := nrf52832_xxaa 3 | OUTPUT_DIRECTORY := _build 4 | 5 | SDK_ROOT := ../../../../../.. 6 | PROJ_DIR := ../../.. 7 | 8 | $(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \ 9 | LINKER_SCRIPT := twi_master_using_app_twi_gcc_nrf52.ld 10 | # Source files common to all targets 11 | SRC_FILES += \ 12 | $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \ 13 | $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \ 14 | $(SDK_ROOT)/components/libraries/button/app_button.c \ 15 | $(SDK_ROOT)/components/libraries/util/app_error.c \ 16 | $(SDK_ROOT)/components/libraries/util/app_error_weak.c \ 17 | $(SDK_ROOT)/components/libraries/timer/app_timer.c \ 18 | $(SDK_ROOT)/components/libraries/twi/app_twi.c \ 19 | $(SDK_ROOT)/components/libraries/util/app_util_platform.c \ 20 | $(SDK_ROOT)/components/libraries/util/nrf_assert.c \ 21 | $(SDK_ROOT)/components/drivers_nrf/clock/nrf_drv_clock.c \ 22 | $(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \ 23 | $(SDK_ROOT)/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \ 24 | $(SDK_ROOT)/components/drivers_nrf/rtc/nrf_drv_rtc.c \ 25 | $(SDK_ROOT)/components/drivers_nrf/twi_master/nrf_drv_twi.c \ 26 | $(SDK_ROOT)/components/drivers_nrf/uart/nrf_drv_uart.c \ 27 | $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c \ 28 | $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c \ 29 | $(PROJ_DIR)/../../../examples/bsp/bsp.c \ 30 | $(PROJ_DIR)/main.c \ 31 | $(SDK_ROOT)/external/segger_rtt/RTT_Syscalls_GCC.c \ 32 | $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \ 33 | $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \ 34 | $(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf52.S \ 35 | $(SDK_ROOT)/components/toolchain/system_nrf52.c \ 36 | 37 | # Include folders common to all targets 38 | INC_FOLDERS += \ 39 | $(PROJ_DIR)/config/twi_master_using_app_twi_pesky \ 40 | $(PROJ_DIR)/config \ 41 | $(SDK_ROOT)/components \ 42 | ../config \ 43 | $(PROJ_DIR) \ 44 | $(PROJ_DIR)/../../common \ 45 | $(SDK_ROOT)/examples/bsp \ 46 | $(SDK_ROOT)/components/drivers_nrf/delay \ 47 | $(SDK_ROOT)/components/toolchain/cmsis/include \ 48 | $(SDK_ROOT)/components/libraries/util \ 49 | $(SDK_ROOT)/components/drivers_nrf/uart \ 50 | $(SDK_ROOT)/components/device \ 51 | $(SDK_ROOT)/components/libraries/log \ 52 | $(SDK_ROOT)/components/libraries/button \ 53 | $(SDK_ROOT)/components/libraries/timer \ 54 | $(SDK_ROOT)/components/drivers_nrf/twi_master \ 55 | $(SDK_ROOT)/components/drivers_nrf/gpiote \ 56 | $(SDK_ROOT)/external/segger_rtt \ 57 | $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \ 58 | $(SDK_ROOT)/components/toolchain \ 59 | $(SDK_ROOT)/components/drivers_nrf/hal \ 60 | $(SDK_ROOT)/components/toolchain/gcc \ 61 | $(SDK_ROOT)/components/drivers_nrf/rtc \ 62 | $(SDK_ROOT)/components/drivers_nrf/common \ 63 | $(SDK_ROOT)/components/libraries/twi \ 64 | $(SDK_ROOT)/components/drivers_nrf/clock \ 65 | $(SDK_ROOT)/components/libraries/log/src \ 66 | 67 | # Libraries common to all targets 68 | LIB_FILES += \ 69 | 70 | # C flags common to all targets 71 | CFLAGS += -DNRF52_PAN_12 72 | CFLAGS += -DNRF52_PAN_15 73 | CFLAGS += -DNRF52_PAN_58 74 | CFLAGS += -DSWI_DISABLE0 75 | CFLAGS += -DNRF52_PAN_20 76 | CFLAGS += -DNRF52_PAN_54 77 | CFLAGS += -DNRF52_PAN_31 78 | CFLAGS += -DNRF52_PAN_30 79 | CFLAGS += -DNRF52_PAN_51 80 | CFLAGS += -DNRF52_PAN_36 81 | CFLAGS += -DNRF52_PAN_53 82 | CFLAGS += -DCONFIG_GPIO_AS_PINRESET 83 | CFLAGS += -DNRF52_PAN_64 84 | CFLAGS += -DNRF52_PAN_55 85 | CFLAGS += -DNRF52_PAN_62 86 | CFLAGS += -DNRF52_PAN_63 87 | CFLAGS += -DBOARD_CUSTOM 88 | CFLAGS += -DNRF52 89 | CFLAGS += -DNRF52832 90 | CFLAGS += -mcpu=cortex-m4 91 | CFLAGS += -mthumb -mabi=aapcs 92 | CFLAGS += -Wall -Werror -O3 -g3 93 | CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 94 | # keep every function in separate section, this allows linker to discard unused ones 95 | CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing 96 | CFLAGS += -fno-builtin --short-enums 97 | # generate dependency output file 98 | CFLAGS += -MP -MD 99 | 100 | # C++ flags common to all targets 101 | CXXFLAGS += \ 102 | 103 | # Assembler flags common to all targets 104 | ASMFLAGS += -x assembler-with-cpp 105 | ASMFLAGS += -DNRF52_PAN_12 106 | ASMFLAGS += -DNRF52_PAN_15 107 | ASMFLAGS += -DNRF52_PAN_58 108 | ASMFLAGS += -DSWI_DISABLE0 109 | ASMFLAGS += -DNRF52_PAN_20 110 | ASMFLAGS += -DNRF52_PAN_54 111 | ASMFLAGS += -DNRF52_PAN_31 112 | ASMFLAGS += -DNRF52_PAN_30 113 | ASMFLAGS += -DNRF52_PAN_51 114 | ASMFLAGS += -DNRF52_PAN_36 115 | ASMFLAGS += -DNRF52_PAN_53 116 | ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET 117 | ASMFLAGS += -DNRF52_PAN_64 118 | ASMFLAGS += -DNRF52_PAN_55 119 | ASMFLAGS += -DNRF52_PAN_62 120 | ASMFLAGS += -DNRF52_PAN_63 121 | ASMFLAGS += -DBOARD_CUSTOM 122 | ASMFLAGS += -DNRF52 123 | ASMFLAGS += -DNRF52832 124 | 125 | # Linker flags 126 | LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT) 127 | LDFLAGS += -mcpu=cortex-m4 128 | LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 129 | # let linker to dump unused sections 130 | LDFLAGS += -Wl,--gc-sections 131 | # use newlib in nano version 132 | LDFLAGS += --specs=nano.specs -lc -lnosys 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | .PHONY: $(TARGETS) default all clean help flash 141 | # Default target - first one defined 142 | default: nrf52832_xxaa 143 | 144 | # Print all targets that can be built 145 | help: 146 | @echo following targets are available: 147 | @echo nrf52832_xxaa 148 | 149 | TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc 150 | 151 | include $(TEMPLATE_PATH)/Makefile.common 152 | $(foreach target, $(TARGETS), $(call define_target, $(target))) 153 | -include $(foreach target, $(TARGETS), $($(target)_dependencies)) 154 | 155 | # Flash the program 156 | flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex 157 | @echo Flashing: $< 158 | nrfjprog --program $< -f nrf52 --chiperase 159 | nrfjprog --reset -f nrf52 160 | 161 | -------------------------------------------------------------------------------- /peripheral/twi_master_using_app_twi/pesky/blank/armgcc/twi_master_using_app_twi_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /peripheral/uart/README.md: -------------------------------------------------------------------------------- 1 | # UART 2 | 3 | This example shows basic usage of UART it is the same as nRF52 SDK example, only Makefile were modified to use appropriate BSP include, board name and flash target. 4 | 5 | For exact pins used please look at BSP: **custom_board.h**. 6 | 7 | Also, don't forget that you should switch pins when connecting to COM port: RX should go to TX, TX to RX, CTS -> RTS and RTS -> CTS. 8 | 9 | Compile, flash, connect to COM port (I used putty with next settings): 10 | 11 | ![image](https://cloud.githubusercontent.com/assets/14309815/19628151/f503b782-995f-11e6-89bf-109c17cf663b.png) 12 | 13 | And you should see something like this: 14 | 15 | ![image](https://cloud.githubusercontent.com/assets/14309815/19628159/2ab25adc-9960-11e6-8581-5bfd97764f87.png) 16 | -------------------------------------------------------------------------------- /peripheral/uart/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * @defgroup uart_example_main main.c 15 | * @{ 16 | * @ingroup uart_example 17 | * @brief UART Example Application main file. 18 | * 19 | * This file contains the source code for a sample application using UART. 20 | * 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include "app_uart.h" 27 | #include "app_error.h" 28 | #include "nrf_delay.h" 29 | #include "nrf.h" 30 | #include "bsp.h" 31 | 32 | //#define ENABLE_LOOPBACK_TEST /**< if defined, then this example will be a loopback test, which means that TX should be connected to RX to get data loopback. */ 33 | 34 | #define MAX_TEST_DATA_BYTES (15U) /**< max number of test bytes to be used for tx and rx. */ 35 | #define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */ 36 | #define UART_RX_BUF_SIZE 256 /**< UART RX buffer size. */ 37 | 38 | void uart_error_handle(app_uart_evt_t * p_event) 39 | { 40 | if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR) 41 | { 42 | APP_ERROR_HANDLER(p_event->data.error_communication); 43 | } 44 | else if (p_event->evt_type == APP_UART_FIFO_ERROR) 45 | { 46 | APP_ERROR_HANDLER(p_event->data.error_code); 47 | } 48 | } 49 | 50 | 51 | 52 | #ifdef ENABLE_LOOPBACK_TEST 53 | /** @brief Function for setting the @ref ERROR_PIN high, and then enter an infinite loop. 54 | */ 55 | static void show_error(void) 56 | { 57 | 58 | LEDS_ON(LEDS_MASK); 59 | while (true) 60 | { 61 | // Do nothing. 62 | } 63 | } 64 | 65 | 66 | /** @brief Function for testing UART loop back. 67 | * @details Transmitts one character at a time to check if the data received from the loopback is same as the transmitted data. 68 | * @note @ref TX_PIN_NUMBER must be connected to @ref RX_PIN_NUMBER) 69 | */ 70 | static void uart_loopback_test() 71 | { 72 | uint8_t * tx_data = (uint8_t *)("\r\nLOOPBACK_TEST\r\n"); 73 | uint8_t rx_data; 74 | 75 | // Start sending one byte and see if you get the same 76 | for (uint32_t i = 0; i < MAX_TEST_DATA_BYTES; i++) 77 | { 78 | uint32_t err_code; 79 | while (app_uart_put(tx_data[i]) != NRF_SUCCESS); 80 | 81 | nrf_delay_ms(10); 82 | err_code = app_uart_get(&rx_data); 83 | 84 | if ((rx_data != tx_data[i]) || (err_code != NRF_SUCCESS)) 85 | { 86 | show_error(); 87 | } 88 | } 89 | return; 90 | } 91 | 92 | 93 | #endif 94 | 95 | 96 | /** 97 | * @brief Function for main application entry. 98 | */ 99 | int main(void) 100 | { 101 | LEDS_CONFIGURE(LEDS_MASK); 102 | LEDS_OFF(LEDS_MASK); 103 | uint32_t err_code; 104 | const app_uart_comm_params_t comm_params = 105 | { 106 | RX_PIN_NUMBER, 107 | TX_PIN_NUMBER, 108 | RTS_PIN_NUMBER, 109 | CTS_PIN_NUMBER, 110 | APP_UART_FLOW_CONTROL_ENABLED, 111 | false, 112 | UART_BAUDRATE_BAUDRATE_Baud115200 113 | }; 114 | 115 | APP_UART_FIFO_INIT(&comm_params, 116 | UART_RX_BUF_SIZE, 117 | UART_TX_BUF_SIZE, 118 | uart_error_handle, 119 | APP_IRQ_PRIORITY_LOW, 120 | err_code); 121 | 122 | APP_ERROR_CHECK(err_code); 123 | 124 | #ifndef ENABLE_LOOPBACK_TEST 125 | printf("\r\nStart: \r\n"); 126 | 127 | while (true) 128 | { 129 | uint8_t cr; 130 | while (app_uart_get(&cr) != NRF_SUCCESS); 131 | while (app_uart_put(cr) != NRF_SUCCESS); 132 | 133 | if (cr == 'q' || cr == 'Q') 134 | { 135 | printf(" \r\nExit!\r\n"); 136 | 137 | while (true) 138 | { 139 | // Do nothing. 140 | } 141 | } 142 | } 143 | #else 144 | 145 | // This part of the example is just for testing the loopback . 146 | while (true) 147 | { 148 | uart_loopback_test(); 149 | } 150 | #endif 151 | } 152 | 153 | 154 | /** @} */ 155 | -------------------------------------------------------------------------------- /peripheral/uart/pesky/blank/armgcc/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME := uart_pesky 2 | TARGETS := nrf52832_xxaa 3 | OUTPUT_DIRECTORY := _build 4 | 5 | SDK_ROOT := ../../../../../.. 6 | PROJ_DIR := ../../.. 7 | 8 | $(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \ 9 | LINKER_SCRIPT := uart_gcc_nrf52.ld 10 | # Source files common to all targets 11 | SRC_FILES += \ 12 | $(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf52.S \ 13 | $(SDK_ROOT)/components/toolchain/system_nrf52.c \ 14 | $(PROJ_DIR)/main.c \ 15 | $(SDK_ROOT)/components/libraries/util/app_error.c \ 16 | $(SDK_ROOT)/components/libraries/util/app_error_weak.c \ 17 | $(SDK_ROOT)/components/libraries/fifo/app_fifo.c \ 18 | $(SDK_ROOT)/components/libraries/uart/app_uart_fifo.c \ 19 | $(SDK_ROOT)/components/libraries/util/app_util_platform.c \ 20 | $(SDK_ROOT)/components/libraries/util/nrf_assert.c \ 21 | $(SDK_ROOT)/components/libraries/uart/retarget.c \ 22 | $(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \ 23 | $(SDK_ROOT)/components/drivers_nrf/uart/nrf_drv_uart.c \ 24 | 25 | # Include folders common to all targets 26 | INC_FOLDERS += \ 27 | $(PROJ_DIR)/config/uart_pesky \ 28 | $(PROJ_DIR)/config \ 29 | $(SDK_ROOT)/components \ 30 | $(SDK_ROOT)/components/libraries/util \ 31 | $(SDK_ROOT)/components/toolchain/gcc \ 32 | $(SDK_ROOT)/components/drivers_nrf/uart \ 33 | ../config \ 34 | $(SDK_ROOT)/components/drivers_nrf/common \ 35 | $(PROJ_DIR) \ 36 | $(PROJ_DIR)/../../common \ 37 | $(SDK_ROOT)/examples/bsp \ 38 | $(SDK_ROOT)/components/libraries/fifo \ 39 | $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \ 40 | $(SDK_ROOT)/components/toolchain \ 41 | $(SDK_ROOT)/components/libraries/uart \ 42 | $(SDK_ROOT)/components/device \ 43 | $(SDK_ROOT)/components/libraries/log \ 44 | $(SDK_ROOT)/components/drivers_nrf/delay \ 45 | $(SDK_ROOT)/components/toolchain/cmsis/include \ 46 | $(SDK_ROOT)/components/drivers_nrf/hal \ 47 | $(SDK_ROOT)/components/libraries/log/src \ 48 | 49 | # Libraries common to all targets 50 | LIB_FILES += \ 51 | 52 | # C flags common to all targets 53 | CFLAGS += -DNRF52_PAN_12 54 | CFLAGS += -DNRF52_PAN_15 55 | CFLAGS += -DNRF52_PAN_58 56 | CFLAGS += -DSWI_DISABLE0 57 | CFLAGS += -DNRF52_PAN_20 58 | CFLAGS += -DNRF52_PAN_54 59 | CFLAGS += -DNRF52_PAN_31 60 | CFLAGS += -DNRF52_PAN_30 61 | CFLAGS += -DNRF52_PAN_51 62 | CFLAGS += -DNRF52_PAN_36 63 | CFLAGS += -DNRF52_PAN_53 64 | CFLAGS += -DCONFIG_GPIO_AS_PINRESET 65 | CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS 66 | CFLAGS += -DNRF52_PAN_64 67 | CFLAGS += -DNRF52_PAN_55 68 | CFLAGS += -DNRF52_PAN_62 69 | CFLAGS += -DNRF52_PAN_63 70 | CFLAGS += -DBOARD_CUSTOM 71 | CFLAGS += -DNRF52 72 | CFLAGS += -DNRF52832 73 | CFLAGS += -DBSP_DEFINES_ONLY 74 | CFLAGS += -mcpu=cortex-m4 75 | CFLAGS += -mthumb -mabi=aapcs 76 | CFLAGS += -Wall -Werror -O3 -g3 77 | CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 78 | # keep every function in separate section, this allows linker to discard unused ones 79 | CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing 80 | CFLAGS += -fno-builtin --short-enums 81 | # generate dependency output file 82 | CFLAGS += -MP -MD 83 | 84 | # C++ flags common to all targets 85 | CXXFLAGS += \ 86 | 87 | # Assembler flags common to all targets 88 | ASMFLAGS += -x assembler-with-cpp 89 | ASMFLAGS += -DNRF52_PAN_12 90 | ASMFLAGS += -DNRF52_PAN_15 91 | ASMFLAGS += -DNRF52_PAN_58 92 | ASMFLAGS += -DSWI_DISABLE0 93 | ASMFLAGS += -DNRF52_PAN_20 94 | ASMFLAGS += -DNRF52_PAN_54 95 | ASMFLAGS += -DNRF52_PAN_31 96 | ASMFLAGS += -DNRF52_PAN_30 97 | ASMFLAGS += -DNRF52_PAN_51 98 | ASMFLAGS += -DNRF52_PAN_36 99 | ASMFLAGS += -DNRF52_PAN_53 100 | ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET 101 | ASMFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS 102 | ASMFLAGS += -DNRF52_PAN_64 103 | ASMFLAGS += -DNRF52_PAN_55 104 | ASMFLAGS += -DNRF52_PAN_62 105 | ASMFLAGS += -DNRF52_PAN_63 106 | ASMFLAGS += -DBOARD_CUSTOM 107 | ASMFLAGS += -DNRF52 108 | ASMFLAGS += -DNRF52832 109 | ASMFLAGS += -DBSP_DEFINES_ONLY 110 | 111 | # Linker flags 112 | LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT) 113 | LDFLAGS += -mcpu=cortex-m4 114 | LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 115 | # let linker to dump unused sections 116 | LDFLAGS += -Wl,--gc-sections 117 | # use newlib in nano version 118 | LDFLAGS += --specs=nano.specs -lc -lnosys 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | .PHONY: $(TARGETS) default all clean help flash 127 | # Default target - first one defined 128 | default: nrf52832_xxaa 129 | 130 | # Print all targets that can be built 131 | help: 132 | @echo following targets are available: 133 | @echo nrf52832_xxaa 134 | 135 | TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc 136 | 137 | include $(TEMPLATE_PATH)/Makefile.common 138 | $(foreach target, $(TARGETS), $(call define_target, $(target))) 139 | -include $(foreach target, $(TARGETS), $($(target)_dependencies)) 140 | 141 | # Flash the program 142 | flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex 143 | @echo Flashing: $< 144 | nrfjprog --program $< -f nrf52 --chiperase 145 | nrfjprog --reset -f nrf52 146 | 147 | -------------------------------------------------------------------------------- /peripheral/uart/pesky/blank/armgcc/uart_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /prepare_hex.sh: -------------------------------------------------------------------------------- 1 | hex_dir=../../../hex 2 | dirs=($(find . -name armgcc -type d)) 3 | 4 | for dir in "${dirs[@]}"; do 5 | echo 6 | pushd "$dir" && echo 7 | # make clean && echo 8 | make && echo 9 | hex_name=$(echo $dir | sed "s|./[^/]*/||; s|/armgcc|.hex|; s|/|_|g") 10 | mkdir -pv $hex_dir && echo 11 | cp -pvu _build/nrf52832_xxaa.hex $hex_dir/$hex_name && echo 12 | popd && echo 13 | echo ------------------------ 14 | done 15 | -------------------------------------------------------------------------------- /segger/rtt/README.md: -------------------------------------------------------------------------------- 1 | # Segger RTT 2 | 3 | This example shows basic usage of SEGGER Real Time Transfer - https://www.segger.com/jlink-rtt.html. 4 | 5 | Also shows how to use app_timer to provider timestamps to logs. 6 | 7 | Compile, flash, open RTT Viewer and you should see colorful logs: 8 | 9 | ![image](https://cloud.githubusercontent.com/assets/14309815/18481819/599d5ba6-79e6-11e6-87ce-b93739f0e086.png) 10 | -------------------------------------------------------------------------------- /segger/rtt/main.c: -------------------------------------------------------------------------------- 1 | #include "nrf_log_ctrl.h" 2 | #include "nrf_log.h" 3 | #include "nrf_delay.h" 4 | 5 | #include "app_timer.h" 6 | #include "nrf_drv_clock.h" 7 | 8 | #define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */ 9 | #define APP_TIMER_OP_QUEUE_SIZE 4 /**< Size of timer operation queues. */ 10 | #define APP_TIMER_MS(TICKS, PRESCALER)\ 11 | ((uint32_t)ROUNDED_DIV((TICKS) * ((PRESCALER) + 1) * 1000, (uint64_t)APP_TIMER_CLOCK_FREQ)) 12 | 13 | char p_data[] = "data"; 14 | int length = 4; 15 | float val = 0.214; 16 | char string_on_stack[] = "Testing string on stack\r\n"; 17 | 18 | uint32_t ticks_from = 0; 19 | uint32_t timestamp_ms = 0; 20 | 21 | uint32_t timestamp_func(void) { 22 | uint32_t ticks_diff = 0; 23 | uint32_t ms_diff = 0; 24 | uint32_t ticks_to = app_timer_cnt_get(); 25 | 26 | APP_ERROR_CHECK(app_timer_cnt_diff_compute(ticks_to, ticks_from, &ticks_diff)); 27 | ticks_from = ticks_to; 28 | 29 | ms_diff = APP_TIMER_MS(ticks_diff, APP_TIMER_PRESCALER); 30 | 31 | timestamp_ms += ms_diff; 32 | 33 | return timestamp_ms; 34 | } 35 | 36 | // Function starting the internal LFCLK oscillator. 37 | // This is needed by RTC1 which is used by the application timer 38 | // (When SoftDevice is enabled the LFCLK is always running and this is not needed). 39 | static void lfclk_request(void) 40 | { 41 | uint32_t err_code = nrf_drv_clock_init(); 42 | APP_ERROR_CHECK(err_code); 43 | nrf_drv_clock_lfclk_request(NULL); 44 | } 45 | 46 | static void timer_handler(void * p_context) 47 | { 48 | NRF_LOG_INFO("Tetsing timer...\r\n"); 49 | } 50 | 51 | int main(void) 52 | { 53 | lfclk_request(); 54 | APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); 55 | APP_TIMER_DEF(m_timer_id); 56 | APP_ERROR_CHECK(app_timer_create(&m_timer_id, APP_TIMER_MODE_REPEATED, timer_handler)); 57 | APP_ERROR_CHECK(app_timer_start(m_timer_id, APP_TIMER_TICKS(10000, APP_TIMER_PRESCALER), NULL)); 58 | 59 | APP_ERROR_CHECK(NRF_LOG_INIT(timestamp_func)); 60 | 61 | while (true) 62 | { 63 | // do 64 | NRF_LOG_DEBUG("Tetsing debug...\r\n"); 65 | NRF_LOG_INFO("Tetsing info...\r\n"); 66 | NRF_LOG_WARNING("Tetsing warning...\r\n"); 67 | NRF_LOG_ERROR("Testing error...\r\n"); 68 | 69 | NRF_LOG_INFO("Testing %d bytes, data:\r\n", length); 70 | NRF_LOG_HEXDUMP_INFO(p_data, length); 71 | 72 | NRF_LOG_INFO("Testing float value:" NRF_LOG_FLOAT_MARKER "\r\n", NRF_LOG_FLOAT(val)); 73 | 74 | // nrf_log_push() copies the string into the logger buffer and returns address from the logger buffer 75 | NRF_LOG_INFO("%s", nrf_log_push(string_on_stack)); 76 | 77 | while (NRF_LOG_PROCESS()) ; 78 | 79 | nrf_delay_ms(1000); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /segger/rtt/pesky/blank/armgcc/rtt_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /segger/rtt/pesky/s132/armgcc/rtt_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000 9 | RAM (rwx) : ORIGIN = 0x200013c8, LENGTH = 0xec38 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | --------------------------------------------------------------------------------