restyle
This commit is contained in:
parent
a93b746839
commit
a97d98549f
1 changed files with 29 additions and 10 deletions
|
@ -56,15 +56,34 @@ int usbio_set_register_bit(struct usb_device *usb_dev, u8 reg, u8 reg_bit, u8 va
|
|||
|
||||
static int usbio_pwm_init(struct usb_device *usb_dev)
|
||||
{
|
||||
usbio_set_register_bit(usb_dev, ANSELD, 5, 0);
|
||||
usbio_set_register_bit(usb_dev, TRISD, 5, 1);
|
||||
usbio_set_register_bit(usb_dev, PSTR1CON, 1, 1);
|
||||
usbio_set_register_bit(usb_dev, TRISD, 5, 0);
|
||||
usbio_set_register(usb_dev, CCPTMRS, 0x00);
|
||||
usbio_set_register(usb_dev, PR2, 199);
|
||||
usbio_set_register(usb_dev, CCP1CON, 0b00001100);
|
||||
usbio_set_register(usb_dev, CCPR1L, 0x00);
|
||||
usbio_set_register(usb_dev, T2CON, 0b00000110);
|
||||
int i, error = 0;
|
||||
static const u8 register_bit_to_set[3][3] = {
|
||||
{ ANSELD, 5, 0 },
|
||||
{ TRISD, 5, 1 },
|
||||
{ PSTR1CON, 1, 1 }
|
||||
};
|
||||
static const u8 register_to_set[5][2] = {
|
||||
{ CCPTMRS, 0x00 }, /* select timer resource */
|
||||
{ PR2, 199 }, /* load width PWM period value */
|
||||
{ CCP1CON, 0b00001100 }, /* enable pwm mode bit(3-0), bit(5-4) LSB PWM duty cycle */
|
||||
{ CCPR1L, 0x00 },
|
||||
{ T2CON, 0b00000110 }
|
||||
};
|
||||
for(i = 0; i < 3; i++) {
|
||||
error = usbio_set_register_bit(usb_dev,
|
||||
register_bit_to_set[i][0],
|
||||
register_bit_to_set[i][1],
|
||||
register_bit_to_set[i][2]);
|
||||
if(error < 0)
|
||||
return error;
|
||||
}
|
||||
for(i = 0; i < 5; i++) {
|
||||
error = usbio_set_register(usb_dev,
|
||||
register_to_set[i][0],
|
||||
register_to_set[i][1]);
|
||||
if(error < 0)
|
||||
return error;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -107,7 +126,7 @@ static int usbio_led_probe(struct usb_interface *interface, const struct usb_dev
|
|||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
error:
|
||||
printk("errors");
|
||||
kfree(led);
|
||||
|
|
Loading…
Reference in a new issue