9const char *getPort(
void *portRef) {
12 if(portRef == (
void*)&PORTA) {
return "PORTA"; }
15 if(portRef == (
void*)&PORTB) {
return "PORTB"; }
18 if(portRef == (
void*)&PORTC) {
return "PORTC"; }
21 if(portRef == (
void*)&PORTD) {
return "PORTD"; }
24 if(portRef == (
void*)&PORTE) {
return "PORTE"; }
27 if(portRef == (
void*)&PORTF) {
return "PORTF"; }
30 if(portRef == (
void*)&PORTG) {
return "PORTG"; }
33 if(portRef == (
void*)&PORTH) {
return "PORTH"; }
36 if(portRef == (
void*)&PORTI) {
return "PORTI"; }
39 if(portRef == (
void*)&PORTJ) {
return "PORTJ"; }
42 if(portRef == (
void*)&PORTK) {
return "PORTK"; }
45 if(portRef == (
void*)&PORTL) {
return "PORTL"; }
50 if(portRef == (
void*)&GPIO_A_PDOR) {
return "GPIO_A_PDOR"; }
53 if(portRef == (
void*)&GPIO_B_PDOR) {
return "GPIO_B_PDOR"; }
56 if(portRef == (
void*)&GPIO_C_PDOR) {
return "GPIO_C_PDOR"; }
59 if(portRef == (
void*)&GPIO_D_PDOR) {
return "GPIO_D_PDOR"; }
62 if(portRef == (
void*)&GPIO_E_PDOR) {
return "GPIO_E_PDOR"; }
65 if(portRef == (
void*)®_PIO_A_ODSR) {
return "REG_PIO_A_ODSR"; }
68 if(portRef == (
void*)®_PIO_B_ODSR) {
return "REG_PIO_B_ODSR"; }
71 if(portRef == (
void*)®_PIO_C_ODSR) {
return "REG_PIO_C_ODSR"; }
74 if(portRef == (
void*)®_PIO_D_ODSR) {
return "REG_PIO_D_ODSR"; }
79 if(portRef == (
void*)&GPIO1_DR) {
return "GPIO1_DR"; }
82if(portRef == (
void*)&GPIO2_DR) {
return "GPIO21_DR"; }
85if(portRef == (
void*)&GPIO3_DR) {
return "GPIO3_DR"; }
88if(portRef == (
void*)&GPIO4_DR) {
return "GPIO4_DR"; }
90 String unknown_str =
"Unknown: " + String((
size_t)portRef, HEX);
91 strncpy(fullstrBuffer, unknown_str.c_str(), unknown_str.length());
92 fullstrBuffer[
sizeof(fullstrBuffer)-1] =
'\0';
96template<u
int8_t PIN>
void CheckPin()
100 void *systemThinksPortIs = (
void*)portOutputRegister(digitalPinToPort(PIN));
101 RwReg systemThinksMaskIs = digitalPinToBitMask(PIN);
103 Serial.print(
"Pin "); Serial.print(PIN); Serial.print(
": Port ");
106 Serial.print(
"valid & mask ");
108 Serial.print(
"invalid, is "); Serial.print(getPort((
void*)
FastPin<PIN>::port())); Serial.print(
" should be ");
109 Serial.print(getPort((
void*)systemThinksPortIs));
110 Serial.print(
" & mask ");
114 Serial.println(
"valid.");
116 Serial.print(
"invalid, is "); Serial.print(
FastPin<PIN>::mask()); Serial.print(
" should be "); Serial.println(systemThinksMaskIs);
120template<>
void CheckPin<255> () {}
123template<u
int8_t _PORT>
const char *_GetPinPort(
void *ptr) {
127 return _GetPinPort<_PORT - 1>(ptr);
130template<>
const char *_GetPinPort<-1>(
void *ptr) {
134const char *GetPinPort(
void *ptr) {
135 return _GetPinPort<'Z'>(ptr);
138static uint8_t pcount = 0;
141template<u
int8_t PIN>
void PrintPins() {
142 PrintPins<PIN - 1>();
144 RwReg *systemThinksPortIs = portOutputRegister(digitalPinToPort(PIN));
145 RwReg systemThinksMaskIs = digitalPinToBitMask(PIN);
148 while(systemThinksMaskIs > 1) { systemThinksMaskIs >>= 1; maskBit++; }
150 const char *pinport = GetPinPort((
void*)systemThinksPortIs);
152 Serial.print(
"__FL_DEFPIN("); Serial.print(PIN);
153 Serial.print(
","); Serial.print(maskBit);
154 Serial.print(
","); Serial.print(pinport);
157 if(pcount == 4) { pcount = 0; Serial.println(
""); }
163template<>
void PrintPins<0>() {
164 RwReg *systemThinksPortIs = portOutputRegister(digitalPinToPort(0));
165 RwReg systemThinksMaskIs = digitalPinToBitMask(0);
168 while(systemThinksMaskIs > 1) { systemThinksMaskIs >>= 1; maskBit++; }
170 const char *pinport = GetPinPort((
void*)systemThinksPortIs);
172 Serial.print(
"__FL_DEFPIN("); Serial.print(0);
173 Serial.print(
","); Serial.print(maskBit);
174 Serial.print(
","); Serial.print(pinport);
177 if(pcount == 4) { pcount = 0; Serial.println(
""); }
185 Serial.println(
"resetting!");
189 Serial.println(counter);
195 Serial.println(
"-----");
196#ifdef NUM_DIGITAL_PINS
197 PrintPins<NUM_DIGITAL_PINS>();
199 Serial.println(
"------");
central include file for FastLED, defines the CFastLED class/object
The simplest level of Pin class.
Utility template for tracking down information about pins and ports.
static const char * portName()
Gets the name of the port, as a C-string.