Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
a6eb5ccb
Commit
a6eb5ccb
authored
Oct 18, 2015
by
devsaurus
Browse files
improved default handling of clock_div and databit length
parent
26f4bc79
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/spi.c
View file @
a6eb5ccb
...
@@ -38,7 +38,8 @@ static int spi_setup( lua_State *L )
...
@@ -38,7 +38,8 @@ static int spi_setup( lua_State *L )
}
}
if
(
clock_div
<
4
)
{
if
(
clock_div
<
4
)
{
return
luaL_error
(
L
,
"invalid clock divider"
);
// defaulting to 8
clock_div
=
8
;
}
}
spi_databits
[
id
]
=
databits
;
spi_databits
[
id
]
=
databits
;
...
@@ -260,6 +261,7 @@ const LUA_REG_TYPE spi_map[] =
...
@@ -260,6 +261,7 @@ const LUA_REG_TYPE spi_map[] =
{
LSTRKEY
(
"CPHA_HIGH"
),
LNUMVAL
(
PLATFORM_SPI_CPHA_HIGH
)
},
{
LSTRKEY
(
"CPHA_HIGH"
),
LNUMVAL
(
PLATFORM_SPI_CPHA_HIGH
)
},
{
LSTRKEY
(
"CPOL_LOW"
),
LNUMVAL
(
PLATFORM_SPI_CPOL_LOW
)
},
{
LSTRKEY
(
"CPOL_LOW"
),
LNUMVAL
(
PLATFORM_SPI_CPOL_LOW
)
},
{
LSTRKEY
(
"CPOL_HIGH"
),
LNUMVAL
(
PLATFORM_SPI_CPOL_HIGH
)
},
{
LSTRKEY
(
"CPOL_HIGH"
),
LNUMVAL
(
PLATFORM_SPI_CPOL_HIGH
)
},
{
LSTRKEY
(
"DATABITS_8"
),
LNUMVAL
(
8
)
},
#endif // #if LUA_OPTIMIZE_MEMORY > 0
#endif // #if LUA_OPTIMIZE_MEMORY > 0
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
...
@@ -278,8 +280,8 @@ LUALIB_API int luaopen_spi( lua_State *L )
...
@@ -278,8 +280,8 @@ LUALIB_API int luaopen_spi( lua_State *L )
MOD_REG_NUMBER
(
L
,
"CPHA_HIGH"
,
PLATFORM_SPI_CPHA_HIGH
);
MOD_REG_NUMBER
(
L
,
"CPHA_HIGH"
,
PLATFORM_SPI_CPHA_HIGH
);
MOD_REG_NUMBER
(
L
,
"CPOL_LOW"
,
PLATFORM_SPI_CPOL_LOW
);
MOD_REG_NUMBER
(
L
,
"CPOL_LOW"
,
PLATFORM_SPI_CPOL_LOW
);
MOD_REG_NUMBER
(
L
,
"CPOL_HIGH"
,
PLATFORM_SPI_CPOL_HIGH
);
MOD_REG_NUMBER
(
L
,
"CPOL_HIGH"
,
PLATFORM_SPI_CPOL_HIGH
);
MOD_REG_NUMBER
(
L
,
"DATABITS_8"
,
8
);
return
1
;
return
1
;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment