Add PWM comments for N2
This commit is contained in:
committed by
Joshua Yang
parent
50e35741d1
commit
cff00afd39
@@ -632,6 +632,10 @@ static int _digitalWrite (int pin, int value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
// PWM signal ___-----------___________---------------_______-----_
|
||||
// <--value--> <----value---->
|
||||
// <-------range--------><-------range-------->
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int _pwmWrite (int pin, int value)
|
||||
{
|
||||
@@ -733,6 +737,11 @@ static int _digitalWriteByte (const unsigned int value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
// PWM signal ___-----------___________---------------_______-----_
|
||||
// <--value--> <----value---->
|
||||
// <-------range--------><-------range-------->
|
||||
// PWM frequency == (PWM clock) / range
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static void _pwmSetRange (unsigned int range)
|
||||
{
|
||||
@@ -743,10 +752,20 @@ static void _pwmSetRange (unsigned int range)
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
// Internal clock == 24MHz
|
||||
// PWM clock == (Internal clock) / divisor
|
||||
// PWM frequency == (PWM clock) / range
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static void _pwmSetClock (int divisor)
|
||||
{
|
||||
divisor = (divisor - 1) & 0x7F;
|
||||
if((divisor < 1) || (divisor > 128))
|
||||
{
|
||||
msg(MSG_ERR,
|
||||
"Set the clock prescaler (divisor) to 1 or more and 128 or less.: %s\n",
|
||||
strerror (errno));
|
||||
}
|
||||
divisor = (divisor - 1);
|
||||
|
||||
for(uint16_t i = 1; i < 3; ++i) {
|
||||
*( pwm[i] + N2_PWM_MISC_REG_01_OFFSET ) = \
|
||||
|
||||
Reference in New Issue
Block a user