Skip to content
Merged
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
106 changes: 106 additions & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Compile Examples

on:
pull_request:
paths:
- ".github/workflows/compile-examples.yml"
- "examples/**"
- "src/**"
push:
paths:
- ".github/workflows/compile-examples.yml"
- "examples/**"
- "src/**"

jobs:
build:
runs-on: ubuntu-latest

env:
SKETCHES_REPORTS_PATH: sketches-reports

strategy:
fail-fast: false

matrix:
board:
- fqbn: arduino:avr:uno
platforms: |
- name: arduino:avr
- fqbn: arduino:samd:mkr1000
platforms: |
- name: arduino:samd
- fqbn: arduino:samd:mkrzero
platforms: |
- name: arduino:samd
- fqbn: arduino:samd:mkrwifi1010
platforms: |
- name: arduino:samd
- fqbn: arduino:samd:mkrfox1200
platforms: |
- name: arduino:samd
- fqbn: arduino:samd:mkrwan1300
platforms: |
- name: arduino:samd
- fqbn: arduino:samd:mkrwan1310
platforms: |
- name: arduino:samd
- fqbn: arduino:samd:mkrgsm1400
platforms: |
- name: arduino:samd
- fqbn: arduino:samd:mkrnb1500
platforms: |
- name: arduino:samd
- fqbn: arduino:samd:mkrvidor4000
platforms: |
- name: arduino:samd
- fqbn: arduino:mbed_rp2040:pico
platforms: |
- name: arduino:mbed_rp2040
- fqbn: arduino:mbed_portenta:envie_m7
platforms: |
- name: arduino:mbed_portenta
- fqbn: arduino:mbed_portenta:envie_m4
platforms: |
- name: arduino:mbed_portenta
- fqbn: arduino:mbed_nano:nano33ble
platforms: |
- name: arduino:mbed_nano
- fqbn: arduino:mbed_nano:nanorp2040connect
platforms: |
- name: arduino:mbed_nano
- fqbn: arduino:mbed_edge:edge_control
platforms: |
- name: arduino:mbed_edge
- fqbn: esp32:esp32:esp32
platforms: |
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
- fqbn: rp2040:rp2040:rpipico
platforms: |
- name: rp2040:rp2040
source-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install ESP32 platform dependencies
if: startsWith(matrix.board.fqbn, 'esp32:esp32')
run: pip3 install pyserial

- name: Compile examples
uses: arduino/compile-sketches@v1
with:
fqbn: ${{ matrix.board.fqbn }}
platforms: ${{ matrix.board.platforms }}
enable-deltas-report: true
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Save memory usage change report as artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v3
with:
name: ${{ env.SKETCHES_REPORTS_PATH }}
path: ${{ env.SKETCHES_REPORTS_PATH }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# IDE related files
.vscode/
.idea/

# Build related folders
build/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# MagAlpha library
[![Compile Examples](https://github.com/monolithicpower/MagAlpha-Arduino-Library/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/monolithicpower/MagAlpha-Arduino-Library/actions/workflows/compile-examples.yml)

Arduino library for the MPS MagAlpha magnetic angle sensor.

## About
Expand Down
4 changes: 2 additions & 2 deletions examples/edit-magalpha-config/edit-magalpha-config.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void loop() {
uint16_t angleRaw16;
uint8_t angleRaw8;

Serial.println("Read Angle using differents methods:");
Serial.println("Read Angle using different methods:");

//Read the angle in degree (Read 16-bit raw angle value and then convert it to the 0-360 degree range)
angle = magAlpha.readAngle();
Expand All @@ -49,7 +49,7 @@ void loop() {

//Read the angle (16-bit raw angle value) and check the parity bit to detect possible communication error
bool error;
angleRaw16 = magAlpha.readAngleRaw16(&error);
angleRaw16 = magAlpha.readAngleRaw(&error);
Serial.print(" magAlpha.readAngleRaw16(&error) = ");
Serial.print(angleRaw16, DEC);
if (error == true){
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=MagAlpha Angle Sensor Library
version=1.0.1
version=1.0.2
author=Mathieu Kaelin, Monolithic Power Systems <sensors@monolithicpower.com>
maintainer=Mathieu Kaelin <sensors@monolithicpower.com>
sentence=Arduino library for the MPS MagAlpha magnetic angle sensor.
Expand Down
7 changes: 6 additions & 1 deletion src/MagAlpha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void MagAlpha::begin(int32_t spiSclkFrequency, uint8_t spiMode, uint8_t spiChip
}

void MagAlpha::end(){
SPI.endTransaction();
SPI.end();
}

Expand Down Expand Up @@ -132,12 +133,14 @@ uint8_t MagAlpha::writeRegister(uint8_t address, uint8_t value){

void MagAlpha::setSpiClockFrequency(uint32_t speedMaximum){
_speedMaximum = speedMaximum;
SPI.endTransaction();
SPI.beginTransaction(SPISettings(_speedMaximum, MSBFIRST, _spiMode));
}

void MagAlpha::setSpiDataMode(uint8_t spiMode){
_spiMode = spiMode;
SPI.setDataMode(_spiMode);
SPI.endTransaction();
SPI.beginTransaction(SPISettings(_speedMaximum, MSBFIRST, _spiMode));
}

void MagAlpha::setSpiChipSelectPin(uint8_t spiChipSelectPin){
Expand Down Expand Up @@ -167,6 +170,7 @@ void MagAlphaSSI::begin(int32_t ssiSsckFrequency){
}

void MagAlphaSSI::end(){
SPI.endTransaction();
SPI.end();
}

Expand Down Expand Up @@ -234,6 +238,7 @@ uint16_t MagAlphaSSI::readAngleRaw(bool* error){

void MagAlphaSSI::setSsiClockFrequency(uint32_t speedMaximum){
_speedMaximum = speedMaximum;
SPI.endTransaction();
SPI.beginTransaction(SPISettings(_speedMaximum, MSBFIRST, SSI_MODE));
}

Expand Down