Git Product home page Git Product logo

atsam4-hal's Introduction

Microchip/Atmel ATSAM4 HAL for Rust

This repository holds the Hardware Abstraction Layer Crate for the Microchip/Atmel ATSAM4 microcontroller family.

Build Status Docs Crates.io Crates.io Crates.io

NOTE: This crate is still under active development. Currently only the ATSAM4E, ATSAM4N and ATSAM4S are supported.

License

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

atsam4-hal's People

Contributors

haata avatar john-terrell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

haata afoht hiszd

atsam4-hal's Issues

Add support for USART

Should be similar to UART in the simplest implementation.

USART has some additional functionality (probably should only be implemented on an is needed basis):

  • Hardware serial pins: SCK, RTS, CTS, DCD, DTR, DSR, RI
  • RS485
  • ISO7816 (Smart Cardsz)
  • IrDA
  • SPI Mode
  • Loop back mode

Add support for Timers (TC)

atsam4s_a, atsam4s_b

  • 1 Timer Module (3 Channels)
  • 16bit registers
    atsam4s_c
  • 2 Timer Modules (2x3 Channels)
  • 16bit registers
    atsam4e
  • 3 Timer Modules (3x3 Channels)
  • 32bit registers

Only basic timer functionality for now.
Out-of-scope features

  • Wave mode
  • Chaining timer channels
  • External clock input

Add support for PWM module

The PWM module on atsam4 is a bit confusing as it has High and Low output pins. I believe these are intentioned for motor controllers as they are inverted pairs.

Effectively there are 4 PWM channels for both atsam4e and atsam4s.

Clock configuration is also a bit confusing.
There are 4 channels, but only 2 fully customizable clocks (see CLKA and CLKB). These clocks can be used on multiple channels (as well as a bunch of peripheral clock divisions). See 39.6.1 (either atsam4s or atsam4e) for more details.

https://docs.rs/embedded-hal/0.2.4/embedded_hal/trait.Pwm.html
https://docs.rs/embedded-hal/0.2.4/embedded_hal/trait.PwmPin.html

Add support for Real-time Timer (RTT)

Should be similar to #18

Has the same functionality between atsam4s and atsam4e.

Has two different types of interrupts:

  • RTTINC (Real-time Timer Increment)
  • ALMS (Alarm)

RTTINC can only use SLCK and has a 16-bit prescaler available

ALMS can be set using the 1HZ or SLCK clocks and has a 32-bit counter. When using the SLCK, the 16-bit prescaler can also be used.

The advantage of this timer is that it can handle very long durations (2^32 or about 136 years). I'm interested in using this timer because it frees up TC channels on atsam4s_a and atsam4s_b which only have 3 TC channels.

atsamd Mode 0 looks similar to RTT with the 32-bit counter: https://github.com/atsamd-rs/atsamd/blob/master/hal/src/common/rtc.rs

Add support for Enhanced Embedded Flash Controller (EEFC)

While not necessary to run code, there are a number of useful features in the EEFC.

  • Setting GPNVMx bits (bootloader or main flash on boot)
  • Reading Unique Identifier
  • Erase flash (all, plane, sector, page)
  • Write flash
  • Read/Write/Erase user signature
  • Handle multiple flash controllers (EFC0 and EFC1 for dual bank MCUs)

Possibly useful

  • Lock regions (usually these are set during programming)

Note: There are some oddities with EEFC_FCMD_EWP where not all pages can be automatically erased when writing. This usually has to do with the page size (can't seem to find the datasheet/reference that I saw). My note in the BOSSA commit: kiibohd/BOSSA@599fae1

Add support for TWI (I2C) module

At minimum we should implement I2C master (atsamd doesn't have an I2C slave implementation afaict).
https://github.com/atsamd-rs/atsamd/blob/master/hal/src/common/thumbv7em/sercom/v1/i2c.rs
https://docs.rs/embedded-hal/0.2.4/embedded_hal/blocking/i2c/index.html

Both atsam4s and atsam4e have two TWI modules.

Ideally with optional support for PDC, but this can get complicated as it's actually less efficient to use PDC for I2C when the transfer sizes are small. So it's probably best to ignore this for now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.