Add PWM control

This commit is contained in:
Jeremy Soller 2019-09-30 09:02:53 -06:00
parent 35a869bb49
commit 3fb1ecd84b
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
5 changed files with 55 additions and 3 deletions

View File

@ -1,8 +1,8 @@
# Parameter for current board # Parameter for current board
#BOARD?=system76/galp3-c BOARD?=system76/galp3-c
#BOARD?=arduino/mega2560 #BOARD?=arduino/mega2560
#BOARD?=arduino/micro #BOARD?=arduino/micro
BOARD?=arduino/uno #BOARD?=arduino/uno
# Set build directory # Set build directory
BUILD=build/$(BOARD) BUILD=build/$(BOARD)

View File

@ -0,0 +1,8 @@
#ifndef _BOARD_PWM_H
#define _BOARD_PWM_H
#include <ec/pwm.h>
void pwm_init(void);
#endif // _BOARD_PWM_H

View File

@ -9,6 +9,7 @@
#include <board/kbscan.h> #include <board/kbscan.h>
#include <board/pmc.h> #include <board/pmc.h>
#include <board/ps2.h> #include <board/ps2.h>
#include <board/pwm.h>
void external_0(void) __interrupt(0) { void external_0(void) __interrupt(0) {
printf("external_0\n"); printf("external_0\n");
@ -40,8 +41,9 @@ void init(void) {
kbc_init(); kbc_init();
pmc_init(); pmc_init();
kbscan_init(); kbscan_init();
pwm_init();
//TODO: INTC, PECI, PWM, SMBUS //TODO: INTC, PECI, SMBUS
// 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
} }

View File

@ -0,0 +1,8 @@
#include <board/pwm.h>
void pwm_init(void) {
// Set T0CHSEL to TACH0A and T1CHSEL to TACH1A
TSWCTLR = 0;
// Turn on the CPU fan at full blast (temperature control TODO)
DCR2 = 0xFF;
}

View File

@ -0,0 +1,34 @@
#ifndef _EC_PWM_H
#define _EC_PWM_H
#include <stdint.h>
// Duty cycle register 0
__xdata volatile uint8_t __at(0x1802) DCR0;
// Duty cycle register 1
__xdata volatile uint8_t __at(0x1803) DCR1;
// Duty cycle register 2
__xdata volatile uint8_t __at(0x1804) DCR2;
// Duty cycle register 3
__xdata volatile uint8_t __at(0x1805) DCR3;
// Duty cycle register 4
__xdata volatile uint8_t __at(0x1806) DCR4;
// Duty cycle register 5
__xdata volatile uint8_t __at(0x1807) DCR5;
// Duty cycle register 6
__xdata volatile uint8_t __at(0x1808) DCR6;
// Duty cycle register 7
__xdata volatile uint8_t __at(0x1809) DCR7;
// Fan one tachometer least significant byte reading register
__xdata volatile uint8_t __at(0x181E) F1TLRR;
// Fan one tachometer most significant byte reading register
__xdata volatile uint8_t __at(0x181F) F1TMRR;
// Fan two tachometer least significant byte reading register
__xdata volatile uint8_t __at(0x1820) F2TLRR;
// Fan two tachometer most significant byte reading register
__xdata volatile uint8_t __at(0x1821) F2TMRR;
// Tachometer switch control register
__xdata volatile uint8_t __at(0x1848) TSWCTLR;
#endif // _EC_PWM_H