Skip to content

Commit 75cdb95

Browse files
authored
Fix #45 support STM32 set I2C pins (#46)
- fix #45 support STM32 set I2C pins ARDUINO_ARCH_STM32 - update readme badges - minor edits
1 parent 319985d commit 75cdb95

File tree

7 files changed

+55
-9
lines changed

7 files changed

+55
-9
lines changed

AS5600.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: AS56000.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.4.0
4+
// VERSION: 0.4.1
55
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
66
// DATE: 2022-05-28
77
// URL: https://github.com/RobTillaart/AS5600
@@ -79,6 +79,32 @@ bool AS5600::begin(int dataPin, int clockPin, uint8_t directionPin)
7979
#endif
8080

8181

82+
#if defined (ARDUINO_ARCH_STM32)
83+
84+
bool AS5600::begin(int dataPin, int clockPin, uint8_t directionPin)
85+
{
86+
_directionPin = directionPin;
87+
if (_directionPin != AS5600_SW_DIRECTION_PIN)
88+
{
89+
pinMode(_directionPin, OUTPUT);
90+
}
91+
setDirection(AS5600_CLOCK_WISE);
92+
93+
if ((dataPin < 255) && (clockPin < 255))
94+
{
95+
_wire->setSDA(dataPin);
96+
_wire->setSCL(clockPin);
97+
_wire->begin();
98+
} else {
99+
_wire->begin();
100+
}
101+
if (! isConnected()) return false;
102+
return true;
103+
}
104+
105+
#endif
106+
107+
82108
bool AS5600::begin(uint8_t directionPin)
83109
{
84110
_directionPin = directionPin;
@@ -331,7 +357,7 @@ uint16_t AS5600::rawAngle()
331357
int16_t value = readReg2(AS5600_RAW_ANGLE) & 0x0FFF;
332358
if (_offset > 0) value = (value + _offset) & 0x0FFF;
333359

334-
if ((_directionPin == AS5600_SW_DIRECTION_PIN) &&
360+
if ((_directionPin == AS5600_SW_DIRECTION_PIN) &&
335361
(_direction == AS5600_COUNTERCLOCK_WISE))
336362
{
337363
value = (4096 - value) & 0x0FFF;
@@ -345,7 +371,7 @@ uint16_t AS5600::readAngle()
345371
uint16_t value = readReg2(AS5600_ANGLE) & 0x0FFF;
346372
if (_offset > 0) value = (value + _offset) & 0x0FFF;
347373

348-
if ((_directionPin == AS5600_SW_DIRECTION_PIN) &&
374+
if ((_directionPin == AS5600_SW_DIRECTION_PIN) &&
349375
(_direction == AS5600_COUNTERCLOCK_WISE))
350376
{
351377
value = (4096 - value) & 0x0FFF;

AS5600.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: AS5600.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.4.0
5+
// VERSION: 0.4.1
66
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
77
// DATE: 2022-05-28
88
// URL: https://github.com/RobTillaart/AS5600
@@ -12,7 +12,7 @@
1212
#include "Wire.h"
1313

1414

15-
#define AS5600_LIB_VERSION (F("0.4.0"))
15+
#define AS5600_LIB_VERSION (F("0.4.1"))
1616

1717
// default addresses
1818
const uint8_t AS5600_DEFAULT_ADDRESS = 0x36;
@@ -89,10 +89,11 @@ class AS5600
8989
public:
9090
AS5600(TwoWire *wire = &Wire);
9191

92-
#if defined (ESP8266) || defined(ESP32)
92+
#if defined (ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_STM32)
9393
// AS5600_SW_DIRECTION_PIN is software controlled direction pin
9494
bool begin(int dataPin, int clockPin, uint8_t directionPin = AS5600_SW_DIRECTION_PIN);
9595
#endif
96+
9697
bool begin(uint8_t directionPin = AS5600_SW_DIRECTION_PIN);
9798
bool isConnected();
9899

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

77

8+
## [0.4.1] - 2023-09-16
9+
- fix #45 support STM32 set I2C pins ARDUINO_ARCH_STM32
10+
- update readme badges
11+
- minor edits
12+
13+
814
## [0.4.0] - 2023-06-27
915
- fix #39 support for Wire2 on ESP32
1016
- update readme.md

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
[![Arduino CI](https://github.com/RobTillaart/AS5600/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
33
[![Arduino-lint](https://github.com/RobTillaart/AS5600/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/AS5600/actions/workflows/arduino-lint.yml)
44
[![JSON check](https://github.com/RobTillaart/AS5600/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/AS5600/actions/workflows/jsoncheck.yml)
5+
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/AS5600.svg)](https://github.com/RobTillaart/AS5600/issues)
6+
57
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/AS5600/blob/master/LICENSE)
68
[![GitHub release](https://img.shields.io/github/release/RobTillaart/AS5600.svg?maxAge=3600)](https://github.com/RobTillaart/AS5600/releases)
9+
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/AS5600.svg)](https://registry.platformio.org/libraries/robtillaart/AS5600)
710

811

912
# AS5600
@@ -683,3 +686,12 @@ priority is relative.
683686
- see getAngularSpeed()
684687

685688

689+
## Support
690+
691+
If you appreciate my libraries, you can support the development and maintenance.
692+
Improve the quality of the libraries by providing issues and Pull Requests, or
693+
donate through PayPal or GitHub sponsors.
694+
695+
Thank you,
696+
697+

examples/AS5600_demo_radians/AS5600_demo_radians.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ void setup()
1919

2020
Wire.begin();
2121

22+
// as5600.begin(11, 12, 4); // test for STM32 or ESP32
2223
as5600.begin(4); // set direction pin.
2324
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
2425
}

library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/AS5600.git"
1717
},
18-
"version": "0.4.0",
18+
"version": "0.4.1",
1919
"license": "MIT",
20-
"frameworks": "arduino",
20+
"frameworks": "*",
2121
"platforms": "*",
2222
"headers": "AS5600.h"
2323
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AS5600
2-
version=0.4.0
2+
version=0.4.1
33
author=Rob Tillaart <rob.tillaart@gmail.com>
44
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
55
sentence=Arduino library for AS5600 and AS5600L magnetic rotation meter.

0 commit comments

Comments
 (0)