Skip to content

Commit

Permalink
fixed slaveSelectPin to be OUTPUT an HIGH before initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Code1110 committed Nov 7, 2016
1 parent 95b4b23 commit 934947d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions max7219.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ function M.setup(config)
local MAX7219_REG_DISPLAYTEST = 0x0F

spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 16, 8)
-- Must NOT be done _before_ spi.setup() because that function configures all HSPI* pins for SPI. Hence,
-- if you want to use one of the HSPI* pins for slave select spi.setup() would overwrite that.
gpio.mode(slaveSelectPin, gpio.OUTPUT)
gpio.write(slaveSelectPin, gpio.HIGH)

for i = 1, numberOfModules do
sendByte(i, MAX7219_REG_SCANLIMIT, 7)
Expand All @@ -189,10 +193,6 @@ function M.setup(config)
sendByte(i, MAX7219_REG_SHUTDOWN, 1)
end

-- Must NOT be done _before_ spi.setup() because that function configures all HSPI* pins for SPI. Hence,
-- if you want to use one of the HSPI* pins for slave select spi.setup() would overwrite that.
gpio.mode(slaveSelectPin, gpio.OUTPUT)

M.clear()
end

Expand Down

0 comments on commit 934947d

Please sign in to comment.