123

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
Kovalev_D
Date:
Wed Oct 19 10:55:05 2016 +0000
Revision:
197:7a05523bf588
Parent:
167:bedc0a9d559a
modul

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Diletant 149:abbf7663d27d 1 #include "Device.h"
Diletant 149:abbf7663d27d 2
Diletant 156:e68ee0bcdcda 3 #ifdef DEV_BOARD_HAOYU
Diletant 149:abbf7663d27d 4 #warning "DeviceLightUp.c debug: development board LED1, LED2 in use instead light-up and backlight!!!"
Diletant 149:abbf7663d27d 5 #endif
Diletant 149:abbf7663d27d 6
Diletant 149:abbf7663d27d 7 extern Device device;
Diletant 149:abbf7663d27d 8
Diletant 167:bedc0a9d559a 9 void InitLightUpDefaultSettings(void){
Diletant 149:abbf7663d27d 10 device.lightUp.settings.sequence = 0x0155;
Diletant 149:abbf7663d27d 11 device.lightUp.state.sequence = 0x0000;
Diletant 149:abbf7663d27d 12 device.lightUp.state.enabled = 0;
Diletant 149:abbf7663d27d 13 }
Diletant 149:abbf7663d27d 14
Diletant 167:bedc0a9d559a 15 void InitLightUpState(void) {
Diletant 167:bedc0a9d559a 16 device.lightUp.state.sequence = device.lightUp.settings.sequence;
Diletant 167:bedc0a9d559a 17 device.lightUp.state.enabled = 1;
Diletant 167:bedc0a9d559a 18 }
Diletant 167:bedc0a9d559a 19
Diletant 167:bedc0a9d559a 20 void DeviceStartLightUp(void) {
Diletant 156:e68ee0bcdcda 21 #ifdef DEV_BOARD_HAOYU
Diletant 149:abbf7663d27d 22 //Development board - P3.25: LED1
Diletant 149:abbf7663d27d 23 LPC_PINCON->PINSEL7 &= ~(3<<18); //P3.25 is GPIO pin (write ( 00 ) in bits 19:18 of PISEL7)
Diletant 149:abbf7663d27d 24 LPC_PINCON->PINMODE7 |= (3<<18); //P3.25 pull-down resistor on (write ( 11 ) in bits 19:18 of PINMODE7)
Diletant 149:abbf7663d27d 25 LPC_GPIO3->FIODIR |= (1<<25); //P3.25 is output (write ( 1 ) in bit 25 of FIODIR)
Diletant 149:abbf7663d27d 26 LPC_GPIO3->FIOSET |= (1<<25); //off
Diletant 149:abbf7663d27d 27
Diletant 149:abbf7663d27d 28 //Development board - P3.26: LED2
Diletant 149:abbf7663d27d 29 LPC_PINCON->PINSEL7 &= ~(3<<20); //P3.26 is GPIO pin (write ( 00 ) in bits 21:20 of PISEL7)
Diletant 149:abbf7663d27d 30 LPC_PINCON->PINMODE7 |= (3<<20); //P3.26 pull-down resistor on (write ( 11 ) in bits 21:20 of PINMODE7)
Diletant 149:abbf7663d27d 31 LPC_GPIO3->FIODIR |= (1<<26); //P3.26 is output (write ( 1 ) in bit 26 of FIODIR)
Diletant 149:abbf7663d27d 32 LPC_GPIO3->FIOSET |= (1<<26); //off
Diletant 149:abbf7663d27d 33 #else
Diletant 149:abbf7663d27d 34 //Device - P0.4: Light-up
Diletant 149:abbf7663d27d 35 LPC_PINCON->PINSEL0 &= ~(3<<8); //P0.4 is GPIO pin (write ( 00 ) in bits 9:8 of PISEL0)
Diletant 149:abbf7663d27d 36 LPC_PINCON->PINMODE0 |= (3<<8); //P0.4 pull-down resistor on (write ( 11 ) in bits 9:8 of PINMODE0)
Diletant 149:abbf7663d27d 37 LPC_GPIO0->FIODIR |= (1<<4); //P0.4 is output (write ( 1 ) in bit 4 of FIODIR)
Diletant 149:abbf7663d27d 38 LPC_GPIO0->FIOSET |= (1<<4); //off
Diletant 149:abbf7663d27d 39
Diletant 149:abbf7663d27d 40 //Device - P2.12: Back light
Diletant 149:abbf7663d27d 41 LPC_PINCON->PINSEL3 &= ~(0x00<<24);
Diletant 149:abbf7663d27d 42 LPC_PINCON->PINSEL3 |= (0x00<<24); //P2.12 is GPIO pin (write ( 00 ) in bits 13:12 of PISEL3)
Diletant 149:abbf7663d27d 43 LPC_PINCON->PINMODE3 |= (3<<24); //P2.12 pull-down resistor on (write ( 11 ) in bits 13:12 of PINMODE3)
Diletant 149:abbf7663d27d 44 LPC_GPIO2->FIODIR |= (1<<12); //P2.12 is output (write ( 1 ) in bit 12 of FIODIR)
Diletant 149:abbf7663d27d 45 LPC_GPIO2->FIOSET |= (1<<12); //off
Diletant 149:abbf7663d27d 46 #endif
Diletant 149:abbf7663d27d 47 }
Diletant 149:abbf7663d27d 48
Diletant 161:efd949e8d536 49 void DeviceLightUpDoCycle(void)
Diletant 149:abbf7663d27d 50 {
Diletant 149:abbf7663d27d 51 if (device.lightUp.state.enabled){
Diletant 149:abbf7663d27d 52 if (device.lightUp.state.sequence & 0x01){
Diletant 156:e68ee0bcdcda 53 #ifdef DEV_BOARD_HAOYU
Diletant 149:abbf7663d27d 54 //Development board - P3.25: LED 1 on
Diletant 149:abbf7663d27d 55 LPC_GPIO3->FIOCLR = (1<<25);
Diletant 149:abbf7663d27d 56 //Development board - P3.26: LED 2 on
Diletant 149:abbf7663d27d 57 LPC_GPIO3->FIOCLR = (1<<26);
Diletant 149:abbf7663d27d 58 #else
Diletant 149:abbf7663d27d 59 //Device - P0.4: Light-up on
Diletant 149:abbf7663d27d 60 LPC_GPIO0->FIOCLR = (1<<4);
Diletant 149:abbf7663d27d 61 //Device - P2.12: Back light on
Diletant 149:abbf7663d27d 62 LPC_GPIO2->FIOCLR = (1<<12);
Diletant 149:abbf7663d27d 63 #endif
Diletant 149:abbf7663d27d 64 } else {
Diletant 156:e68ee0bcdcda 65 #ifdef DEV_BOARD_HAOYU
Diletant 149:abbf7663d27d 66 //Development board - P3.25: LED 1 off
Diletant 149:abbf7663d27d 67 LPC_GPIO3->FIOSET = (1<<25);
Diletant 149:abbf7663d27d 68 //Development board - P3.26: LED 2 off
Diletant 149:abbf7663d27d 69 LPC_GPIO3->FIOSET = (1<<26);
Diletant 149:abbf7663d27d 70 #else
Diletant 149:abbf7663d27d 71 //Device - P0.4: Light-up off
Diletant 149:abbf7663d27d 72 LPC_GPIO0->FIOSET = (1<<4);
Diletant 149:abbf7663d27d 73 //Device - P2.12: Back light off
Diletant 149:abbf7663d27d 74 LPC_GPIO2->FIOSET = (1<<12);
Diletant 149:abbf7663d27d 75 #endif
Diletant 149:abbf7663d27d 76 }
Diletant 149:abbf7663d27d 77
Diletant 149:abbf7663d27d 78 if (device.lightUp.state.sequence)
Diletant 149:abbf7663d27d 79 device.lightUp.state.sequence = device.lightUp.state.sequence >> 1;
Diletant 149:abbf7663d27d 80 else
Diletant 149:abbf7663d27d 81 device.lightUp.state.enabled = 0;
Diletant 149:abbf7663d27d 82 }
Diletant 149:abbf7663d27d 83 }