mirror of
https://github.com/sipeed/MaixCDK.git
synced 2026-11-09 17:04:38 -06:00
* spi support setting hw cs pin
This commit is contained in:
@@ -42,10 +42,11 @@ namespace maix::peripheral::spi
|
||||
* @param[in] cs_enable cs pin active level, default is 0(low)
|
||||
* @param[in] soft_cs not use hardware cs, bool type, if set true, you can operate cs pin use gpio manually.
|
||||
* @param[in] cs soft cs pin number, std::string type, default is "GPIOA19", if SPI support multi hardware cs, you can set it to other value.
|
||||
* @param[in] hw_cs_id hardware cs id, int type, default is 0, if SPI support multi hardware cs, you can set it to other value.
|
||||
* @maixpy maix.peripheral.spi.SPI.__init__
|
||||
*/
|
||||
SPI(int id, spi::Mode mode, int freq, int polarity = 0, int phase = 0,
|
||||
int bits = 8, unsigned char cs_enable=0, bool soft_cs = false, std::string cs = "GPIOA19");
|
||||
int bits = 8, unsigned char cs_enable=0, bool soft_cs = false, std::string cs = "GPIOA19", int hw_cs_id = 0);
|
||||
~SPI();
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace maix::peripheral::spi
|
||||
{
|
||||
SPI::SPI(int id, spi::Mode mode, int freq, int polarity, int phase, int bits, unsigned char cs_enable, bool soft_cs, std::string cs)
|
||||
SPI::SPI(int id, spi::Mode mode, int freq, int polarity, int phase, int bits, unsigned char cs_enable, bool soft_cs, std::string cs, int hw_cs_id)
|
||||
{
|
||||
throw err::Exception(err::Err::ERR_NOT_IMPL, "SPI not implemented");
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace maix::peripheral::spi
|
||||
}
|
||||
|
||||
SPI::SPI(int id, spi::Mode mode, int freq, int polarity, int phase,
|
||||
int bits, unsigned char cs_enable, bool soft_cs, std::string cs)
|
||||
int bits, unsigned char cs_enable, bool soft_cs, std::string cs, int hw_cs_id)
|
||||
:_used_soft_cs(soft_cs), _cs_enable(cs_enable), _bits(bits), _freq(freq)
|
||||
{
|
||||
{
|
||||
@@ -87,7 +87,7 @@ namespace maix::peripheral::spi
|
||||
"GPIO as the CS pin.");
|
||||
}
|
||||
|
||||
std::string dev_name("/dev/spidev"+std::to_string(id)+".0");
|
||||
std::string dev_name("/dev/spidev"+std::to_string(id)+"."+std::to_string(hw_cs_id));
|
||||
log::debug("try to open %s...", dev_name.c_str());
|
||||
_fd = ::open(dev_name.c_str(), O_RDWR);
|
||||
if (_fd < 0)
|
||||
|
||||
Reference in New Issue
Block a user