Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions firmware/source/interfaces/SpiMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ CmdStatus SPIMaster::init(uint8_t const *cmd) {
uint32_t baudrate = convertBytesToUInt32(&cmd[2]);

spi_init(_spiInst, baudrate);
spi_set_format(_spiInst, 8, (mode & 0x02) ? SPI_CPOL_1 : SPI_CPOL_0, (mode & 0x01) ? SPI_CPHA_1 : SPI_CPHA_0, SPI_MSB_FIRST);
gpio_set_function(_clkGP, GPIO_FUNC_SPI);
gpio_set_function(_mosiGP, GPIO_FUNC_SPI);
gpio_set_function(_misoGP, GPIO_FUNC_SPI);
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
author='execuc',
author_email='',
license='MIT',
packages=['source/machine'],
packages=['machine'],
package_dir={'machine': 'source/machine'},
zip_safe=False,
install_requires=["pyserial>=3.5", "hid>=1.0.4", "micropython-cpython-ustruct==0.0", "micropython-cpython-micropython==0.1.1"])

Expand Down
5 changes: 2 additions & 3 deletions source/machine/spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ def __init__(self, *, spi_index=0):
def __del__(self):
self.deinit()

def init(self, baudrate=1000000):
def init(self, baudrate=1000000, mode=0x00):
report_id = report_const.SPI0_INIT if self.spi_index == 0 else report_const.SPI1_INIT
mode = 0x00 # to implement
res = self._device.send_report(bytes([report_id, mode]) + baudrate.to_bytes(4, byteorder='little'))
if res[1] != report_const.OK:
raise RuntimeError("SPI init error.")
Expand All @@ -29,7 +28,7 @@ def deinit(self):

def read(self, nbytes, write=0):
buf = bytearray(nbytes)
self.readfrom_into(buf, write)
self._read_from_into(buf, write)
return buf

def readinto(self, buf, write=0):
Expand Down