Skip to content
This repository was archived by the owner on Nov 19, 2022. It is now read-only.

Commit 3901521

Browse files
committed
Reimplements PWM functions
1 parent 2fa485a commit 3901521

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

cores/scirocco/wiring_analog.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ void _analogReadResolution(int res)
6060

6161
void analogWrite( uint32_t ulPin, uint32_t ulValue )
6262
{
63-
pwm_pin_set_cycles(NULL, ulPin, pwm_resolution, ulValue);
63+
struct device* dev = device_get_binding(W_PWM_DEV_NAME(ulPin));
64+
if(!dev) return;
65+
66+
pwm_pin_set_cycles(dev, ulPin, pwm_resolution, ulValue);
6467
}
6568

6669
void analogWriteResolution(int res)

cores/scirocco/wiring_private.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,29 @@
3232
extern "C" {
3333
#endif
3434

35+
#ifndef W_GPIO_PINS_PER_PORT
3536
#define W_GPIO_PINS_PER_PORT 32
37+
#endif
38+
39+
#ifndef W_GPIO_PORT_NUM
3640
#define W_GPIO_PORT_NUM (sizeof(gpio_port_names)/sizeof(const char*))
41+
#endif
42+
43+
#ifndef W_PIN2PORT
3744
#define W_PIN2PORT(x) (gpio_port_names[x / W_GPIO_PINS_PER_PORT])
45+
#endif
46+
47+
#ifndef W_PIN2PORTPIN
3848
#define W_PIN2PORTPIN(x) (x % W_GPIO_PINS_PER_PORT)
49+
#endif
50+
51+
#ifndef W_GPIO_PIN_NUM
3952
#define W_GPIO_PIN_NUM (W_GPIO_PINS_PER_PORT * W_GPIO_PORT_NUM)
53+
#endif
54+
55+
#ifndef W_PWM_DEV_NAME
56+
#define W_PWM_DEV_NAME(x) NULL
57+
#endif
4058

4159
typedef void (*voidFuncPtr)(void);
4260

variants/nrf52840_pca10056/prj.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@ CONFIG_UART_INTERRUPT_DRIVEN=y
6868
CONFIG_I2C=y
6969
CONFIG_I2C_NRFX=y
7070
CONFIG_I2C_0=y
71+
72+
CONFIG_PWM=y

variants/nrf52840_pca10056/variant.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern "C"
3131

3232
#define GPIO_PORT_NAMES { DT_GPIO_P0_DEV_NAME, DT_GPIO_P1_DEV_NAME }
3333

34+
#define W_PWM_DEV_NAME(x) DT_NORDIC_NRF_PWM_0_LABEL
3435

3536
/*----------------------------------------------------------------------------
3637
* Pins

0 commit comments

Comments
 (0)