Code Monkey home page Code Monkey logo

pslib's Introduction

PSLib - library for stm32 microcontrollers

Just for fun experemental C++ static template library. No source files, only headers.

Example

#include "ps_stm32.h"
#include "ps_sys.h"
#include "ps_gpio.h"
#include "ps_usart.h"
#include "ps_logger.h"
#include "ps_util.h"

using namespace ps;

typedef log::logger< usart_1 > logger;

char itoa32_buff[12];

int main()
{
    gpio_a::enable_clock();
    gpio_a::init(
            gpio::speed_10MHz,
            gpio::mode_af_pp,
            pin::pin_9 | pin::pin_10);

    usart_1::enable_clock();
    usart_1::init(9600);
    usart_1::init_nvic();
    usart_1::enable_it(usart::it::it_rxne);
    usart_1::enable();
    
    usart_1.write("Hello World!\n")

    logger log("main.cpp", log::debug);

    log.debug("System Timer");
    log.debug("\tInitialization...");
    sys::tick_init(1000);
    log.debug("\tDone");

    log.debug("GPIOC");
    log.debug("\tInitialization...");
    gpio_c::enable_clock();
    gpio_c::init(
            gpio::speed_2MHz,
            gpio::mode_out_pp,
            pin::pin_8 | pin::pin_9);
    log.debug("\tDone");
    
    char dma_buff[] = "Hello from DMA!\n";
    usart_1::init_dma_tx();
    usart_1::write_dma((uint8_t*)dma_buff, 16);

    while(1)
    {
        GPIOC->ODR ^= GPIO_Pin_9;
        sys::sleep_ms(200);
        GPIOC->ODR ^= GPIO_Pin_8;
    }
}

pslib's People

Contributors

levsh avatar

Watchers

 avatar  avatar

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.