-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
*PFS_P103PFS_BY = 0x05; // Pulse on D4 to trigger scope
*PFS_P103PFS_BY = 0x04; //
If you change those to writing a full 32bit word, you can simultaneously force the pin to GPIO (PMR bit) and set the drive strength:
const uint32_t pfsHIGH = (0 << R_PFS_PORT_PIN_PmnPFS_PMR_Pos) | //GPIO
(1 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos) | // Middle Drive
(1 << R_PFS_PORT_PIN_PmnPFS_PDR_Pos) | // Output
(1 << R_PFS_PORT_PIN_PmnPFS_PODR_Pos); // output High
const uint32_t pfsLOW = (0 << R_PFS_PORT_PIN_PmnPFS_PMR_Pos) | //GPIO
(1 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos) | // Middle Drive
(1 << R_PFS_PORT_PIN_PmnPFS_PDR_Pos) | // Output
(0 << R_PFS_PORT_PIN_PmnPFS_PODR_Pos); // output High
//
// :
//
static inline __attribute__((always_inline)) void dwfast(unsigned int iopin, unsigned int val);
static inline __attribute__((always_inline)) void dwfast(unsigned int iopin, unsigned int val) {
unsigned int port, bit;
if (__builtin_constant_p(iopin)) {
// magic string constants derived from variant.cpp (this for R4 Minima)
port = "\003\003\001\001\001\001\001\001\003\003\001\001"
"\001\001\000\000\000\000\001\001\005\000\000\005\005\001\003"[iopin];
bit = "\001\002\005\004\003\002\006\007\004\003\012\011"
"\012\013\016\000\001\002\001\000\000\014\015\001\002\010\000"[iopin];
} else {
port = iopin >> IOPORT_PRV_PORT_OFFSET;
bit = iopin & BSP_IO_PRV_8BIT_MASK;
}
volatile R_PFS_PORT_PIN_Type *pfs = &R_PFS->PORT[port].PIN[bit];
if (val) {
pfs->PmnPFS = pfsHIGH;
} else {
pfs->PmnPFS = pfsLOW;
}
}
const byte myled = 13;
void loop() {
0: b508 push {r3, lr}
pfs->PmnPFS = pfsHIGH;
2: 4c08 ldr r4, [pc, #32] ; (24 <loop+0x24>)
4: f240 4505 movw r5, #1029 ; 0x405
8: 6025 str r5, [r4, #0]
// port->POSR = 0x10;
for (;;) {
#if 1
dwfast(myled, HIGH);
delay(300);
a: f44f 7096 mov.w r0, #300 ; 0x12c
e: f7ff fffe bl 0 <delay>
pfs->PmnPFS = pfsLOW;
12: f240 4304 movw r3, #1028 ; 0x404
16: 6023 str r3, [r4, #0]
dwfast(myled, LOW);
delay(300);
18: f44f 7096 mov.w r0, #300 ; 0x12c
1c: f7ff fffe bl 0 <delay>
20: e7f2 b.n 8 <loop+0x8>
22: bf00 nop
24: 4004086c .word 0x4004086c
Metadata
Metadata
Assignees
Labels
No labels