mips-mcu-alloc

Crates.iomips-mcu-alloc
lib.rsmips-mcu-alloc
version0.6.2
sourcesrc
created_at2022-09-26 12:12:42.224706
updated_at2024-02-04 20:18:17.353672
descriptionA heap allocator for MIPS based microcontrollers
homepage
repositoryhttps://github.com/kiffie/pic32-rs/tree/master/mips-mcu-alloc
max_upload_size
id674211
size10,880
Stephan (kiffie)

documentation

README

mips-mcu-alloc

Crates.io docs.rs

A heap allocator for PIC32 microcontrollers (based on the alloc-cortex-m crate)

The heap is placed at a location determined by the linker and automatically extended to fullfil allocation requests. Automatic heap extension fails if the heap would collide with the stack.

Memory allocation and heap extension can be traced via logging by activating the log feature.

Example:

#![feature(global_allocator)]
#![feature(alloc_error_handler)]

// Plug in the allocator crate
extern crate alloc;
use alloc::Vec;
use mips_mcu_alloc::MipsMcuHeap;

#[global_allocator]
static ALLOCATOR: MipsMcuHeap = MipsMcuHeap::empty();

#[entry]
fn main() -> ! {
    ALLOCATOR.init();
    let mut xs = Vec::new();
    xs.push(1);
    loop { /* .. */ }
}

#[alloc_error_handler]
fn alloc_error(layout: core::alloc::Layout) -> ! {
    panic!("Cannot allocate heap memory: {:?}", layout);
}

License

Licensed under either of

at your option.

Commit count: 154

cargo fmt