Skip to content

"USB Mode" & "USB CDC On Boot" menu options #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/M5CoreS3.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#ifndef _M5CORES3_H_
#define _M5CORES3_H_

#if ARDUINO_USB_CDC_ON_BOOT
#define USBSerial Serial
#else
#include <HWCDC.h>
// the warning produced by using the 'inline' keyword is a necessary evil as (HWCDC)USBSerial is declared extern and can't be casted as static
inline HWCDC USBSerial;
#endif

#include <Arduino.h>
#include <Wire.h>
#include "FS.h"
Expand Down Expand Up @@ -40,4 +48,4 @@ extern M5CoreS3 M5;
#define imu IMU
#define Imu IMU

#endif
#endif
6 changes: 3 additions & 3 deletions src/utility/I2C_IMU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bool bmm150_init_flag = false; // FIXME: dirty code

I2C_IMU::I2C_IMU() {
Wire1.begin(12, 11, 100000UL);
USBSerial.begin(115200);
//USBSerial.begin(115200); // wut?
}

I2C_IMU::~I2C_IMU() {
Expand Down Expand Up @@ -93,7 +93,7 @@ void I2C_IMU::Init() {
/* Map data ready interrupt to interrupt pin. */
ret = bmi2_map_data_int(BMI2_DRDY_INT, BMI2_INT1, &aux_bmi2_dev);

USBSerial.printf("Valid BMM150 (Aux) sensor - Chip ID : 0x%x\r\n",
printf("Valid BMM150 (Aux) sensor - Chip ID : 0x%x\r\n",
aux_bmm150_dev.chip_id);

if (aux_bmm150_dev.chip_id == BMM150_CHIP_ID) {
Expand Down Expand Up @@ -270,4 +270,4 @@ float I2C_IMU::lsb_to_dps(int16_t val, float dps, uint8_t bit_width) {
float half_scale = ((float)(1 << bit_width) / 2.0f);

return (dps / ((half_scale))) * (val);
}
}