Coder Social home page Coder Social logo

mm_sspi's Introduction

title keywords description author timestamp version
sspi开源库
sspi,sspi开源库,软件SPI,单片机,嵌入式,开源
软件SPI(Serial Peripheral Interface)在单片机开发中经常被使用,通过模块化的设计简化设计避免重复的工作量。
蒙蒙plus
2024-03-18
1.0.0

sspi开源库

简介

软件SPI(Serial Peripheral Interface)在单片机开发中经常被使用,通过模块化的设计简化设计避免重复的工作量,

名词介绍

简称 全称 中文描述
SSPI soft Serial Peripheral Interface 软串行外围接口

目录介绍

.
├── inc
│   ├── mm_pin.h                #引脚操作头文件
│   ├── mm_sspi_def.h
│   ├── mm_sspi.h
│   └── spi-bit-ops.h
├── port                        #接口移植文件
│   ├── lpc_bare_sspi_port.c
│   ├── lpc_bare_sspi_port.h
│   └── mm_pin_port.c           #引脚操作实现文件
├── readme.md                   #文档
└── src
    ├── mm_sspi.c
    └── spi-bit-ops.c

快速开始

  1. 添加sspi源码到工程中
  2. 添加sspi头文件路径到工程中
  3. 添加引脚操作实现文件到工程中
  4. 添加引脚操作头文件到工程中

示例

#define LD_BLU1 PIN_NUM(2, 13)
#define LD_BLU3 PIN_NUM(1, 27)
#define LD_BLU5 PIN_NUM(1, 29)
#define LD_DEN PIN_NUM(2, 4)
#define LD_GRN5 PIN_NUM(1, 25)
void lpc_bare_sspi_init()
{
    static const struct lpc_soft_spi_config soft_spi_config[] = {
        {.sck = PIN_NUM(2, 4),   // LD_DEN
         .mosi = PIN_NUM(1, 25), // LD_GRN5
         .miso = PIN_NUM(1, 27), // LD_BLU3
         .bus_name = "sspi1"}};

    static struct lpc_soft_spi mm_sspi_bus[ITEM_NUM(soft_spi_config)];
    static uint8_t init_ok = 0;
    if (init_ok)
    {
        return;
    }
    for (int i = 0; i < ITEM_NUM(soft_spi_config); i++)
    {
        mm_sspi_bus[i].spi.data = (void *)&soft_spi_config[i];
        lpc_sspi_gpio_init(&mm_sspi_bus[i]);
        mm_sspi_bit_add_bus(&mm_sspi_bus[i].spi, soft_spi_config[i].bus_name, &sspi_bit_ops);
    }
    static struct mm_sspi_device sspi10 = {
        .config = {
            .mode = MM_SPI_MODE_3 | MM_SPI_MSB,
            .data_width = 8,
            .max_hz = 100000,
        },
    };
    mm_sspi_bus_attach_device_cspin(&sspi10,
                                    "sspi10",
                                    "sspi1",
                                    PIN_NUM(1, 29)); // LD_BLU5
}

贡献

欢迎提交issue和pr.

联系我

您可以通过qq群(790012859)联系到作者

许可证

Apache License 2.0

鸣谢

[1] https://github.com/rt-thread/rt-thread

mm_sspi's People

Contributors

meng-plus avatar

Watchers

 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.