1 Star 0 Fork 0

ma/HarmonInstruments-CP2130

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

CP2130 - Unmaintained

SiLabs CP2130 USB to SPI Llbusb C++ class

The CP2130 is no longer used by Harmon Instruments and this repo will be archived and no longer be maintained.

CP2130 interface spec http://www.silabs.com/Support Documents/TechnicalDocs/AN792.pdf

The writeread (full duplex) transaction doesn't work with longer lengths. 67 bytes works. 260 bytes does not. The documentation is unclear on how this mode works.

It doesn't appear to be possible to do multiple transactions without deasserting CS so the read and write commands are less than useful.

Read the interface spec and be careful with the commands that write to the one time programmable memory.

Example usage

#include <iostream>
#include <stdexcept>
#include <vector>
#include <string>

#include "LibUSB.h"
#include "CP2130.h"
#include "SpiFlash.h"

int main(void)
{
        LibUSB lusb;
        LibUSB_dev d(lusb, 0x10C4, 0x87A0);
        CP2130 spi(&d);

	// set GPIO 2 to push pull and low
	spi.set_gpio(2,2,0);

	// setup to use CS 0
        spi.set_gpio_cs(0, 2);
        spi.set_spi_word(0);

	// get the ID of a SPI flash on CS0
        std::vector<uint8_t> c(4);
        c[0] = 0x9F;
        spi.writeread(c);
        for (auto it = c.begin() ; it != c.end(); ++it)
                std::cout << ' ' << (int) *it << std::endl;

	// Use the SPI flash class to access the same
        SpiFlash f(&spi);
        f.write_file(0, "spi.cpp");
}

The MIT License (MIT) Copyright (c) 2016 Harmon Instruments, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
C++ 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/bingchaoma/harmon-instruments-cp2130.git
git@gitee.com:bingchaoma/harmon-instruments-cp2130.git
bingchaoma
harmon-instruments-cp2130
HarmonInstruments-CP2130
master

搜索帮助