offa() { P2_0=0; xdelay(); P2_1=0; xdelay(); P2_2=0; xdelay(); }
// h1,h2--> p1_0, p1_1 void keyscan(void) { unsigned char n; /* 电路 p1_0 -- R --- + + p1_1 --R--- + + p1_2 行1------------ + p1_3 行2----------------- */ //扫描第一行 P1=0xff; xdelay(); P1=0xfb; //拉低第一行 , 1011 xdelay(); n=P1; if(n!=0xfb){ switch(n){ case(0xf9): led2on;break; case(0xfa): led3on;break; case 0xf8 : led2on;led3on;break; default: led1on;ldelay(); ldelay();led1off; ldelay(); ldelay();break; } } led2off; led3off }
/** * @brief Initialization of GPIO Port F * * @note LED pins set to output */ void GPIO_Init(uint32_t outputs, uint32_t inputs) { GPIOA_Type *gpio; #ifdef USE_AHB gpio = GPIOF_AHB; /* Enable AHB access for Port F */ SYSCTL->GPIOHBCTL |= BIT(5); #else gpio = GPIOF; #endif /* Enable clock for Port F */ SYSCTL->RCGCGPIO |= BIT(5); xdelay(10); /* * To modify PF0, it is necessary to unlock it because it can be used as NMI * See Datasheet: Observation at 10.1 and Commit control in 10.2.4 */ if( (inputs|outputs)&1 ) { gpio->LOCK = 0x4C4F434B; // Unlock to set PF0 = ASCII('LOCB') *(uint32_t * )(&(gpio->CR)) = 1; // CR is marked read-only } /* Pins for led are digital output */ gpio->DIR = outputs; // Only specified bits are outputs gpio->DEN = inputs|outputs; // All pins are digital I/O gpio->PUR = inputs; // Set pull up for inputs xdelay(10); if( (inputs|outputs)&1 ) { gpio->LOCK = 0x0; // Lock again *(uint32_t * )(&(gpio->CR)) = 0x0; // CR is marked read-only } }
int main(int argc, char *argv[]) { float leftlen = 50.0f, rightlen = 60.0f; float feedback = 37.5f; float wetout = 100.0f; int leftlen_smp, rightlen_smp; int i; get_rate(); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-leftlen") && i+1 < argc) leftlen = atof(argv[++i]); else if (!strcmp(argv[i], "-rightlen") && i+1 < argc) rightlen = atof(argv[++i]); else if (!strcmp(argv[i], "-feedback") && i+1 < argc) feedback = atof(argv[++i]); else if (!strcmp(argv[i], "-wetout") && i+1 < argc) wetout = atof(argv[++i]); else if (!strcmp(argv[i], "-help")) { fprintf(stderr, "options: -leftlen ms, -rightlen ms, " "-feedback percent, -wetout percent\n"); exit(0); } } leftlen = CLAMP(0.0f, leftlen, 30000.0f); leftlen_smp = (int)(leftlen * RATE / 1000.0f); if (leftlen_smp == 0) leftlen_smp = 1; rightlen = CLAMP(0.0f, rightlen, 30000.0f); rightlen_smp = (int)(rightlen * RATE / 1000.0f); if (rightlen_smp == 0) rightlen_smp = 1; SET_BINARY_MODE xdelay(leftlen_smp, rightlen_smp, feedback, wetout); return 0; }
/** * @brief Initialization of GPIO Port F * * @note LED pins set to output */ void GPIO_Init(uint32_t outputs, uint32_t inputs) { GPIOA_Type *gpio; #ifdef USE_AHB gpio = GPIOF_AHB; /* Enable AHB access for Port F */ SYSCTL->GPIOHBCTL |= BIT(5); #else gpio = GPIOF; #endif /* Enable clock for Port F */ SYSCTL->RCGCGPIO |= BIT(5); /* Pins for led are digital output */ gpio->DIR = outputs; /* Only specified bits are outputs */ gpio->DEN = inputs|outputs; /* All pins are digital I/O */ xdelay(10); }
ona() { P2_0=1; xdelay(); P2_1=1; xdelay(); P2_2=1; xdelay(); }
/** * @brief Quick and dirty delay routine * * It gives approximately 1ms delay at 4 MHz (MSI) * */ void Delay(uint32_t delay) { xdelay(INTERVAL); }