Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version: 1.0 Release Release License GPLv3

hal-avr0-spi - AVR0 SPI Hardware Abstraction

Ask DeepWiki

The hal-avr0-spi is a lightweight spi hardware abstraction library for AVR0 microcontrollers. It provides a clean interface for spi initialization and communication while hiding direct register-level interaction from higher software layers. The library is intended for projects that want to separate low-level device startup code from application logic and establish a small, reusable system layer for AVR0 targets.

Features

  • SPI master configuration for AVR0 devices.
  • SPI master communication for AVR0 devices.
  • Encapsulation of low-level register access.
  • Compact and reusable API for embedded projects.
  • Foundation for layered HAL architectures.

The hal-avr0-spi library reduces coupling by providing a focused interface for essential spi system services. This improves portability inside a project, keeps startup code organized, and makes higher-level modules easier to maintain.

File Structure

File Structure

hal/
├── common/
|   ├── enums/
|   |   └── SPI_enums.h
|   └── macros/
|       └── PORT_macros.h
└── avr0/
    └── spi/
        ├── spi.c
        └── spi.h

Downloads

The library can be downloaded (zip or tar), cloned or used as submodule in a project.

Type File Description
Library zip / tar AVR0 spi library

Using with git clone

mkdir -p ./hal/
git clone https://github.com/0x007E/hal-common.git ./hal
mv ./hal/hal-common ./hal/common

mkdir -p ./hal/avr0
git clone https://github.com/0x007E/hal-avr0-spi.git ./hal/avr0
mv ./hal/avr0/hal-avr0-spi ./hal/avr0/spi

Using as git submodule

git submodule add https://github.com/0x007E/hal-common.git   ./hal/common
git submodule add https://github.com/0x007E/hal-avr0-spi.git ./hal/avr0/spi

Programming

Additional parameters like spi clock speed, prescaler, pin definitions and many more can be setup in the header file. A user friendly description can be found here.

#include "../hal/avr0/spi/spi.h"

int main(void)
{
	spi_init(SPI_MSB, SPI_Rising, SPI_Rising);

    while (1)
    {
        spi_select(SPI_Enable);

        unsigned char data = 0x00;
        data = spi_transfer(data);

        spi_select(SPI_Disable);
    }
}

Additional Information

Type Link Description
AVR0-Series pdf megaAVR® 0-series family datasheet

R. GAECHTER