File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ extern "C" {
88#include " fbcon.h"
99#include " fractal.h"
1010#include " gpio.h"
11- #include " pwm.h"
1211#include " lcd.h"
1312#include " lowrisc_logo.h"
1413#include " sonata_system.h"
@@ -19,6 +18,7 @@ int coremark_main();
1918}
2019
2120#include " spi.hh"
21+ #include " pwm.hh"
2222#include " platform.hh"
2323
2424#define SIMULATION 0
@@ -94,8 +94,8 @@ int main(void) {
9494 Lcd spi (platform::Spi::SpiLcd);
9595
9696 // Turn on LCD backlight via PWM
97- pwm_t lcd_bl = PWM_FROM_ADDR_AND_INDEX (PWM_BASE, PWM_LCD );
98- set_pwm (lcd_bl, 1 , 255 );
97+ Pwm pwm (platform::Pwm::Pwm6 );
98+ pwm. set ( 1 , 155 );
9999
100100 // Set the initial state of the LCD control pins.
101101 spi.chip_select (false );
Original file line number Diff line number Diff line change 1+ // Copyright lowRISC contributors.
2+ // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+ // SPDX-License-Identifier: Apache-2.0
4+
5+ #pragma once
6+
7+ #include " mmio/pwm.hh"
8+ #include " platform.hh"
9+
10+ class Pwm {
11+ const platform::Pwm base_addr;
12+
13+ public:
14+ constexpr Pwm (platform::Pwm base_addr) : base_addr(base_addr) {}
15+
16+ void set (uint8_t counter, uint8_t pulse_width) {
17+ mmio::pwm::Pwm pwm (base_addr);
18+ pwm.counter .value .write (counter).commit ();
19+ pwm.width .value .write (pulse_width).commit ();
20+ }
21+ };
You can’t perform that action at this time.
0 commit comments