123

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
Diletant
Date:
Sun May 15 19:12:12 2016 +0000
Revision:
161:efd949e8d536
Parent:
156:e68ee0bcdcda
Child:
167:bedc0a9d559a
Device & ... update. Not final!!!

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 149:abbf7663d27d 9 void InitLightUpWithDefaults(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 149:abbf7663d27d 15 void InitLightUp(void)//проверка битового поля поджига и установка значения бита поджига
Diletant 149:abbf7663d27d 16 {
Diletant 156:e68ee0bcdcda 17 #ifdef DEV_BOARD_HAOYU
Diletant 149:abbf7663d27d 18 //Development board - P3.25: LED1
Diletant 149:abbf7663d27d 19 LPC_PINCON->PINSEL7 &= ~(3<<18); //P3.25 is GPIO pin (write ( 00 ) in bits 19:18 of PISEL7)
Diletant 149:abbf7663d27d 20 LPC_PINCON->PINMODE7 |= (3<<18); //P3.25 pull-down resistor on (write ( 11 ) in bits 19:18 of PINMODE7)
Diletant 149:abbf7663d27d 21 LPC_GPIO3->FIODIR |= (1<<25); //P3.25 is output (write ( 1 ) in bit 25 of FIODIR)
Diletant 149:abbf7663d27d 22 LPC_GPIO3->FIOSET |= (1<<25); //off
Diletant 149:abbf7663d27d 23
Diletant 149:abbf7663d27d 24 //Development board - P3.26: LED2
Diletant 149:abbf7663d27d 25 LPC_PINCON->PINSEL7 &= ~(3<<20); //P3.26 is GPIO pin (write ( 00 ) in bits 21:20 of PISEL7)
Diletant 149:abbf7663d27d 26 LPC_PINCON->PINMODE7 |= (3<<20); //P3.26 pull-down resistor on (write ( 11 ) in bits 21:20 of PINMODE7)
Diletant 149:abbf7663d27d 27 LPC_GPIO3->FIODIR |= (1<<26); //P3.26 is output (write ( 1 ) in bit 26 of FIODIR)
Diletant 149:abbf7663d27d 28 LPC_GPIO3->FIOSET |= (1<<26); //off
Diletant 149:abbf7663d27d 29 #else
Diletant 149:abbf7663d27d 30 //Device - P0.4: Light-up
Diletant 149:abbf7663d27d 31 LPC_PINCON->PINSEL0 &= ~(3<<8); //P0.4 is GPIO pin (write ( 00 ) in bits 9:8 of PISEL0)
Diletant 149:abbf7663d27d 32 LPC_PINCON->PINMODE0 |= (3<<8); //P0.4 pull-down resistor on (write ( 11 ) in bits 9:8 of PINMODE0)
Diletant 149:abbf7663d27d 33 LPC_GPIO0->FIODIR |= (1<<4); //P0.4 is output (write ( 1 ) in bit 4 of FIODIR)
Diletant 149:abbf7663d27d 34 LPC_GPIO0->FIOSET |= (1<<4); //off
Diletant 149:abbf7663d27d 35
Diletant 149:abbf7663d27d 36 //Device - P2.12: Back light
Diletant 149:abbf7663d27d 37 LPC_PINCON->PINSEL3 &= ~(0x00<<24);
Diletant 149:abbf7663d27d 38 LPC_PINCON->PINSEL3 |= (0x00<<24); //P2.12 is GPIO pin (write ( 00 ) in bits 13:12 of PISEL3)
Diletant 149:abbf7663d27d 39 LPC_PINCON->PINMODE3 |= (3<<24); //P2.12 pull-down resistor on (write ( 11 ) in bits 13:12 of PINMODE3)
Diletant 149:abbf7663d27d 40 LPC_GPIO2->FIODIR |= (1<<12); //P2.12 is output (write ( 1 ) in bit 12 of FIODIR)
Diletant 149:abbf7663d27d 41 LPC_GPIO2->FIOSET |= (1<<12); //off
Diletant 149:abbf7663d27d 42 #endif
Diletant 149:abbf7663d27d 43 }
Diletant 149:abbf7663d27d 44
Diletant 156:e68ee0bcdcda 45 void DeviceStartLightUp(void)//проверка битового поля поджига и установка значения бита поджига
Diletant 149:abbf7663d27d 46 {
Diletant 149:abbf7663d27d 47 device.lightUp.state.sequence = device.lightUp.settings.sequence;
Diletant 149:abbf7663d27d 48 device.lightUp.state.enabled = 1;
Diletant 149:abbf7663d27d 49 }
Diletant 149:abbf7663d27d 50
Diletant 161:efd949e8d536 51 void DeviceLightUpDoCycle(void)
Diletant 149:abbf7663d27d 52 {
Diletant 149:abbf7663d27d 53 if (device.lightUp.state.enabled){
Diletant 149:abbf7663d27d 54 if (device.lightUp.state.sequence & 0x01){
Diletant 156:e68ee0bcdcda 55 #ifdef DEV_BOARD_HAOYU
Diletant 149:abbf7663d27d 56 //Development board - P3.25: LED 1 on
Diletant 149:abbf7663d27d 57 LPC_GPIO3->FIOCLR = (1<<25);
Diletant 149:abbf7663d27d 58 //Development board - P3.26: LED 2 on
Diletant 149:abbf7663d27d 59 LPC_GPIO3->FIOCLR = (1<<26);
Diletant 149:abbf7663d27d 60 #else
Diletant 149:abbf7663d27d 61 //Device - P0.4: Light-up on
Diletant 149:abbf7663d27d 62 LPC_GPIO0->FIOCLR = (1<<4);
Diletant 149:abbf7663d27d 63 //Device - P2.12: Back light on
Diletant 149:abbf7663d27d 64 LPC_GPIO2->FIOCLR = (1<<12);
Diletant 149:abbf7663d27d 65 #endif
Diletant 149:abbf7663d27d 66 } else {
Diletant 156:e68ee0bcdcda 67 #ifdef DEV_BOARD_HAOYU
Diletant 149:abbf7663d27d 68 //Development board - P3.25: LED 1 off
Diletant 149:abbf7663d27d 69 LPC_GPIO3->FIOSET = (1<<25);
Diletant 149:abbf7663d27d 70 //Development board - P3.26: LED 2 off
Diletant 149:abbf7663d27d 71 LPC_GPIO3->FIOSET = (1<<26);
Diletant 149:abbf7663d27d 72 #else
Diletant 149:abbf7663d27d 73 //Device - P0.4: Light-up off
Diletant 149:abbf7663d27d 74 LPC_GPIO0->FIOSET = (1<<4);
Diletant 149:abbf7663d27d 75 //Device - P2.12: Back light off
Diletant 149:abbf7663d27d 76 LPC_GPIO2->FIOSET = (1<<12);
Diletant 149:abbf7663d27d 77 #endif
Diletant 149:abbf7663d27d 78 }
Diletant 149:abbf7663d27d 79
Diletant 149:abbf7663d27d 80 if (device.lightUp.state.sequence)
Diletant 149:abbf7663d27d 81 device.lightUp.state.sequence = device.lightUp.state.sequence >> 1;
Diletant 149:abbf7663d27d 82 else
Diletant 149:abbf7663d27d 83 device.lightUp.state.enabled = 0;
Diletant 149:abbf7663d27d 84 }
Diletant 149:abbf7663d27d 85 }