Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of AK7451 by
AK7451 Class Reference
This is a device driver of AK7451 with SPI interface. More...
#include <ak7451.h>
Public Types | |
| enum | OperationMode { AK7451_NORMAL_MODE = 0x0000, AK7451_USER_MODE = 0x050F } |
Available opration modes in AK7451. More... | |
| enum | Status { SUCCESS, ERROR, ERROR_IN_USER_MODE, ERROR_IN_NORMAL_MODE, ERROR_PARITY, ERROR_ABNORMAL_STRENGTH } |
Status of function. More... | |
Public Member Functions | |
| AK7451 () | |
| Constructor. | |
| ~AK7451 () | |
| Destructor. | |
| void | begin (SPI *spi, DigitalOut *cs) |
| begin | |
| Status | checkConnection () |
| Check the connection. | |
| Status | writeEEPROM (char address, const char *data) |
| Writes data to EEPROM on the device. | |
| Status | readEEPROM (char address, char *data) |
| Reads data from EEPROM on the device. | |
| Status | writeRegister (char address, const char *data) |
| Writes data to register on the device. | |
| Status | readRegister (char address, char *data) |
| Reads data from register on the device. | |
| Status | setOperationMode (OperationMode mode) |
| Sets device operation mode. | |
| OperationMode | getOperationMode () |
| Gets device operation mode. | |
| Status | readAngle (char *angle) |
| Reads angle data from the device. | |
| Status | readAngleMeasureCommand (char *angle, char *density, char *abnormal_state) |
| Measures and reads angle, magnetic flux density and abnormal state code while in the user mode. | |
| Status | setAngleZero () |
| Measures current angle and sets the value to EEPROM as zero angle position. | |
| Status | setAngleZero (const char *angle) |
| Sets the value to EEPROM as zero angle position. | |
Detailed Description
This is a device driver of AK7451 with SPI interface.
- Note:
- AK7451 is a high speed angle sensor IC manufactured by AKM.
Example:
#include "mbed.h" #include "ak7451.h" int main() { // Creates an instance of SPI }
Definition at line 22 of file ak7451.h.
Member Enumeration Documentation
| enum OperationMode |
| enum Status |
Constructor & Destructor Documentation
| AK7451 | ( | ) |
Constructor.
Definition at line 39 of file ak7451.cpp.
| ~AK7451 | ( | ) |
Destructor.
Definition at line 49 of file ak7451.cpp.
Member Function Documentation
| void begin | ( | SPI * | spi, |
| DigitalOut * | cs | ||
| ) |
begin
- Parameters:
-
*spi pointer to SPI instance *cs pointer to DigitalOut instance for CS
Definition at line 60 of file ak7451.cpp.
| AK7451::Status checkConnection | ( | ) |
Check the connection.
- Note:
- Connection check is performed by reading a register which has a fixed value and verify it.
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another code.
Definition at line 75 of file ak7451.cpp.
| AK7451::OperationMode getOperationMode | ( | ) |
Gets device operation mode.
- Returns:
- Returns OperationMode.
Definition at line 162 of file ak7451.cpp.
| AK7451::Status readAngle | ( | char * | angle ) |
Reads angle data from the device.
- Parameters:
-
angle pointer to read angle data buffer
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another code.
Definition at line 173 of file ak7451.cpp.
| AK7451::Status readAngleMeasureCommand | ( | char * | angle, |
| char * | density, | ||
| char * | abnormal_state | ||
| ) |
Measures and reads angle, magnetic flux density and abnormal state code while in the user mode.
- Parameters:
-
angle pointer to angle data buffer density magnetic flux density abnormal_state abnormal state
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another code.
- Parameters:
-
angle pointer to angle data density magnetic flux density abnormal_state abnormal state
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another code.
Definition at line 204 of file ak7451.cpp.
| AK7451::Status readEEPROM | ( | char | address, |
| char * | data | ||
| ) |
Reads data from EEPROM on the device.
- Parameters:
-
address EEPROM address data data to read
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another.
Definition at line 109 of file ak7451.cpp.
| AK7451::Status readRegister | ( | char | address, |
| char * | data | ||
| ) |
Reads data from register on the device.
- Parameters:
-
address register address data data to read
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another.
Definition at line 133 of file ak7451.cpp.
| AK7451::Status setAngleZero | ( | ) |
Measures current angle and sets the value to EEPROM as zero angle position.
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another code.
Definition at line 239 of file ak7451.cpp.
| AK7451::Status setAngleZero | ( | const char * | angle ) |
Sets the value to EEPROM as zero angle position.
- Parameters:
-
angle zero angle position
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another code.
Definition at line 281 of file ak7451.cpp.
| AK7451::Status setOperationMode | ( | AK7451::OperationMode | mode ) |
Sets device operation mode.
- Parameters:
-
mode device opration mode
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another code.
Definition at line 146 of file ak7451.cpp.
| AK7451::Status writeEEPROM | ( | char | address, |
| const char * | data | ||
| ) |
Writes data to EEPROM on the device.
- Parameters:
-
address EEPROM address data data to be written
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another.
Definition at line 97 of file ak7451.cpp.
| AK7451::Status writeRegister | ( | char | address, |
| const char * | data | ||
| ) |
Writes data to register on the device.
- Parameters:
-
address register address data data to be written
- Returns:
- Returns SUCCESS when succeeded, otherwise returns another.
Definition at line 121 of file ak7451.cpp.
Generated on Thu Jul 14 2022 01:58:56 by
1.7.2
