Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
cfe35805
Commit
cfe35805
authored
Mar 03, 2016
by
Terry Ellison
Browse files
Merge pull request #1110 from pjsg/pwm_module
Omit all the PWM code if the PWM module is not included
parents
ebb0c333
6efbf13e
Changes
3
Show whitespace changes
Inline
Side-by-side
app/modules/pwm.c
View file @
cfe35805
...
...
@@ -122,6 +122,11 @@ static int lpwm_getduty( lua_State* L )
return
1
;
}
int
lpwm_open
(
lua_State
*
L
)
{
platform_pwm_init
();
return
0
;
}
// Module function map
static
const
LUA_REG_TYPE
pwm_map
[]
=
{
{
LSTRKEY
(
"setup"
),
LFUNCVAL
(
lpwm_setup
)
},
...
...
@@ -135,4 +140,4 @@ static const LUA_REG_TYPE pwm_map[] = {
{
LNILKEY
,
LNILVAL
}
};
NODEMCU_MODULE
(
PWM
,
"pwm"
,
pwm_map
,
NULL
);
NODEMCU_MODULE
(
PWM
,
"pwm"
,
pwm_map
,
lpwm_open
);
app/platform/platform.c
View file @
cfe35805
...
...
@@ -32,16 +32,11 @@ static struct gpio_hook platform_gpio_hook;
#endif
#endif
static
void
pwms_init
();
int
platform_init
()
{
// Setup the various forward and reverse mappings for the pins
get_pin_map
();
// Setup PWMs
pwms_init
();
cmn_platform_init
();
// All done
return
PLATFORM_OK
;
...
...
@@ -113,7 +108,9 @@ int platform_gpio_mode( unsigned pin, unsigned mode, unsigned pull )
return
1
;
}
#ifdef LUA_USE_MODULES_PWM
platform_pwm_close
(
pin
);
// closed from pwm module, if it is used in pwm
#endif
if
(
pull
==
PLATFORM_GPIO_PULLUP
)
{
PIN_PULLUP_EN
(
pin_mux
[
pin
]);
...
...
@@ -421,7 +418,7 @@ void platform_uart_send( unsigned id, u8 data )
static
uint16_t
pwms_duty
[
NUM_PWM
]
=
{
0
};
static
void
pwm
s
_init
()
void
platform_
pwm_init
()
{
int
i
;
for
(
i
=
0
;
i
<
NUM_PWM
;
i
++
){
...
...
app/platform/platform.h
View file @
cfe35805
...
...
@@ -70,7 +70,7 @@ enum
ELUA_CAN_ID_EXT
};
static
inline
int
platform_can_exists
(
unsigned
id
)
{
return
id
<
NUM_CAN
;
}
static
inline
int
platform_can_exists
(
unsigned
id
)
{
return
NUM_CAN
&&
(
id
<
NUM_CAN
)
;
}
uint32_t
platform_can_setup
(
unsigned
id
,
uint32_t
clock
);
int
platform_can_send
(
unsigned
id
,
uint32_t
canid
,
uint8_t
idtype
,
uint8_t
len
,
const
uint8_t
*
data
);
int
platform_can_recv
(
unsigned
id
,
uint32_t
*
canid
,
uint8_t
*
idtype
,
uint8_t
*
len
,
uint8_t
*
data
);
...
...
@@ -171,6 +171,7 @@ void platform_uart_alt( int set );
#define DUTY(d) ((uint16_t)( ((unsigned)(d)*PWM_DEPTH) / NORMAL_PWM_DEPTH) )
// The platform PWM functions
void
platform_pwm_init
(
void
);
static
inline
int
platform_pwm_exists
(
unsigned
id
)
{
return
((
id
<
NUM_PWM
)
&&
(
id
>
0
));
}
uint32_t
platform_pwm_setup
(
unsigned
id
,
uint32_t
frequency
,
unsigned
duty
);
void
platform_pwm_close
(
unsigned
id
);
...
...
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