Pass pin to power switch function
This commit is contained in:
		
							
								
								
									
										10
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/main.c
									
									
									
									
									
								
							@@ -47,19 +47,19 @@ void init(void) {
 | 
				
			|||||||
    // PECI information can be found here: https://www.intel.com/content/dam/www/public/us/en/documents/design-guides/core-i7-lga-2011-guide.pdf
 | 
					    // PECI information can be found here: https://www.intel.com/content/dam/www/public/us/en/documents/design-guides/core-i7-lga-2011-guide.pdf
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct Pin PWR_SW = PIN(D, 0);
 | 
					void power_button(struct Pin * button) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
void power_switch(void) {
 | 
					 | 
				
			||||||
    static bool last = false;
 | 
					    static bool last = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Check if the power switch goes low
 | 
					    // Check if the power switch goes low
 | 
				
			||||||
    bool new = pin_get(&PWR_SW);
 | 
					    bool new = pin_get(button);
 | 
				
			||||||
    if (!new && last) {
 | 
					    if (!new && last) {
 | 
				
			||||||
        printf("Power Switch\n");
 | 
					        printf("Power Switch\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    last = new;
 | 
					    last = new;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct Pin PWR_SW = PIN(D, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct Pin LED_BAT_CHG = PIN(A, 5);
 | 
					struct Pin LED_BAT_CHG = PIN(A, 5);
 | 
				
			||||||
struct Pin LED_BAT_FULL = PIN(A, 6);
 | 
					struct Pin LED_BAT_FULL = PIN(A, 6);
 | 
				
			||||||
struct Pin LED_PWR = PIN(A, 7);
 | 
					struct Pin LED_PWR = PIN(A, 7);
 | 
				
			||||||
@@ -78,7 +78,7 @@ void main(void) {
 | 
				
			|||||||
    gpio_debug();
 | 
					    gpio_debug();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for(;;) {
 | 
					    for(;;) {
 | 
				
			||||||
        power_switch();
 | 
					        power_button(&PWR_SW);
 | 
				
			||||||
        kbc_event(&KBC);
 | 
					        kbc_event(&KBC);
 | 
				
			||||||
        pmc_event(&PMC_1);
 | 
					        pmc_event(&PMC_1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user