Skip to content

raulgotor/ams_as5600

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License


AMS AS5600 Driver

C driver for the AMS AS5600 magnetic rotary position sensor
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

  1. Getting Started
  2. Usage
  3. Roadmap
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgements

Getting Started

To get a local copy up and running follow these simple steps.

Installation

  1. Navigate to your project's source directory

  2. Clone the repo

    git clone https://github.com/raulgotor/ams_as5600.git
  3. Write a transfer function (see next section)

Usage

Transfer function

A transfer function is needed by the driver to know how to use the I2C of your specific hardware. Above, a simple example of how this could be implemented for STM32 MCUs using the STM32 HAL Libraries is shown:

I2C_HandleTypeDef * hi2c;

uint32_t const my_i2c_xfer(uint8_t const slave_address,
                           uint8_t const * const p_tx_buffer,
                           size_t const tx_buffer_size,
                           uint8_t * const p_rx_buffer,
                           size_t const rx_buffer_size)
{

        uint32_t const timeout = 100;
        HAL_StatusTypeDef result = HAL_OK;
        bool is_rx_operation = true;
        
        if ((NULL == p_tx_buffer) || (0 == tx_buffer_size)) {
                result = HAL_ERROR;

        } else if ((NULL == p_rx_buffer) || (0 == rx_buffer_size)) {
                is_rx_operation = false;
        }

        if (HAL_OK == result) {
                // TX operation
                result = HAL_I2C_Master_Transmit(hi2c,
                                                 slave_address,
                                                 p_tx_buffer,
                                                 (uint16_t)tx_buffer_size,
                                                 timeout);
        }
        
        if ((HAL_OK == result) && (is_rx_operation)) {
                // RX operation
                result = HAL_I2C_Master_Receive(hi2c,
                                                slave_address,
                                                p_rx_buffer,
                                                rx_buffer_size,
                                                timeout);
        }
        
        return result;
}

Module initialization

After declaring the transfer function, initialize the module with the following call:

as5600_error_t result = as5600_init(my_i2c_xfer);

Further documentation

Please refer to the in code documentation and to the AMS AS5600 Datasheet

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Raúl Gotor

Project Link: https://github.com/raulgotor/ams_as5600

Acknowledgements