Masahiko Fukasawa / AK7451

Fork of AK7451 by AKM Development Platform

Embed: (wiki syntax)

« Back to documentation index

AK7451 Class Reference

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

Available opration modes in AK7451.

Enumerator:
AK7451_NORMAL_MODE 

Normal mode operation.

AK7451_USER_MODE 

User mode operation.

Definition at line 29 of file ak7451.h.

enum Status

Status of function.

Enumerator:
SUCCESS 

The function processed successfully.

ERROR 

General Error.

ERROR_IN_USER_MODE 

Error in user mode.

ERROR_IN_NORMAL_MODE 

Error in normal mode.

ERROR_PARITY 

Parity bit error.

ERROR_ABNORMAL_STRENGTH 

Abnormal strength error.

Definition at line 37 of file ak7451.h.


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:
*spipointer to SPI instance
*cspointer 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:
anglepointer 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:
anglepointer to angle data buffer
densitymagnetic flux density
abnormal_stateabnormal state
Returns:
Returns SUCCESS when succeeded, otherwise returns another code.
Parameters:
anglepointer to angle data
densitymagnetic flux density
abnormal_stateabnormal 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:
addressEEPROM address
datadata 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:
addressregister address
datadata 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:
anglezero 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:
modedevice 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:
addressEEPROM address
datadata 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:
addressregister address
datadata to be written
Returns:
Returns SUCCESS when succeeded, otherwise returns another.

Definition at line 121 of file ak7451.cpp.