Skip to content

Commit c90c01a

Browse files
rizlikdanielinux
authored andcommitted
pic32c-app: use symbolic name for pins offset
1 parent b62ec9d commit c90c01a

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

test-app/app_pic32ck.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,19 @@
4646
#define PORTD_OUTCLR (*(volatile uint32_t *)(PORTD_BASE + 0x14))
4747
#define PORTD_OUTCLR_OUT(X) (1 << (X))
4848

49+
#define LED0_PIN (20)
50+
#define LED1_PIN (25)
51+
4952
static void led0_on(void)
5053
{
51-
PORTD_DIRSET = PORTD_DIRSET_OUT(20);
52-
PORTD_OUTCLR = PORTD_OUTCLR_OUT(20);
54+
PORTD_DIRSET = PORTD_DIRSET_OUT(LED0_PIN);
55+
PORTD_OUTCLR = PORTD_OUTCLR_OUT(LED0_PIN);
5356
}
5457

5558
static void led1_on(void)
5659
{
57-
PORTB_DIRSET = PORTB_DIRSET_OUT(25);
58-
PORTB_OUTCLR = PORTB_OUTCLR_OUT(25);
60+
PORTB_DIRSET = PORTB_DIRSET_OUT(LED1_PIN);
61+
PORTB_OUTCLR = PORTB_OUTCLR_OUT(LED1_PIN);
5962
}
6063

6164
void main(void)

test-app/app_pic32cz.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@
3838
#define PORTB_OUTCLR (*(volatile uint32_t *)(PORTB_BASE + 0x14))
3939
#define PORTB_OUTCLR_OUT(X) (1 << (X))
4040

41+
#define LED0_PIN 21
42+
#define LED1_PIN 22
43+
4144
static void led0_on(void)
4245
{
43-
PORTB_DIRSET = PORTB_DIRSET_OUT(21);
44-
PORTB_OUTCLR = PORTB_OUTCLR_OUT(21);
46+
PORTB_DIRSET = PORTB_DIRSET_OUT(LED0_PIN);
47+
PORTB_OUTCLR = PORTB_OUTCLR_OUT(LED0_PIN);
4548
}
4649

4750
static void led1_on(void)
4851
{
49-
PORTB_DIRSET = PORTB_DIRSET_OUT(22);
50-
PORTB_OUTCLR = PORTB_OUTCLR_OUT(22);
52+
PORTB_DIRSET = PORTB_DIRSET_OUT(LED1_PIN);
53+
PORTB_OUTCLR = PORTB_OUTCLR_OUT(LED1_PIN);
5154
}
5255

5356
void main(void)

0 commit comments

Comments
 (0)