si24r1 - si24r1 Drive#

Adaptation status unknown

Note

This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!

Example

--Note: due to the use of sys.wait() all apis need to be used in the coroutine
-- Usage Examples
local si24r1 = require "si24r1"

sys.taskInit(function()
    spi_si24r1 = spi.setup(0,nil,0,0,8,10*1000*1000,spi.MSB,1,1)
    si24r1.init(0,pin.PB04,pin.PB01,pin.PB00)
    if si24r1.chip_check() then
        si24r1.set()
    end

    --Send Example
    -- si24r1.set_mode( si24r1.MODE_TX );        --Send Mode    
    -- while 1 do
    --     sys.wait(1000)
    --     local a = si24r1.txpacket("si24r1test")
    --     print("a",a)
    -- end

    --Receive Example 
    si24r1.set_mode( si24r1.MODE_RX );        --Receive Mode    
    while 1 do
        local i,data = si24r1.rxpacket( );        --Receive Bytes
        print("rxbuf",i,data)
    end
end)

si24r1.chip_check()#

si24r1 Device detection

Parameters

None

Return Value

return value type

explanation

bool

Successful return true

Examples

if si24r1.chip_check() then
    si24r1.set()
end

si24r1.set_mode( Mode )#

si24r1 Set Mode

Parameters

Incoming Value Type

Explanation

number

Mode si24r1.MODE_TX si24r1.MODE_RX

Return Value

None

Examples

si24r1.set_mode( si24r1.MODE_TX )

si24r1.txpacket(buff)#

si24r1 Send

Parameters

Incoming Value Type

Explanation

string

buff

Return Value

return value type

explanation

number

0x20:Send successfully 0x 10: Maximum number of sends reached Interrupt 0xff: Send failed

Examples

local a = si24r1.txpacket("si24r1test")

si24r1.rxpacket()#

si24r1 Receive

Parameters

None

Return Value

return value type

explanation

number

len,buff Length data

Examples

local i,data = si24r1.rxpacket()        --Receive Bytes
print("rxbuf",i,data)

si24r1.set()#

si24r1 Configuration parameters

Parameters

None

Return Value

None

Examples

si24r1.set()

si24r1.init(spi_id,cs,ce,irq)#

si24r1 Initialization

Parameters

Incoming Value Type

Explanation

number

spi_id spi_id

Return Value

return value type

explanation

bool

Successful return true

Examples

lm75_data.init(0)