int main(void) { // Configure cpu and mandatory peripherals systemInit(); uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; while (1) { // Toggle LED once per second ... rollover = 136 years :) currentSecond = systickGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; if (gpioGetValue(CFG_LED_PORT, CFG_LED_PIN) == CFG_LED_OFF) { gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); } else { gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); } } // Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h #ifdef CFG_INTERFACE cmdPoll(); #endif } return 0; }
void cmdInit() { #if defined CFG_INTERFACE && defined CFG_INTERFACE_UART // Check if UART is already initialised uart_pcb_t *pcb = uartGetPCB(); if (!pcb->initialised) { uartInit(CFG_UART_BAUDRATE); } #endif #if CFG_INTERFACE_ENABLEIRQ != 0 // Set IRQ pin as output gpioSetDir(CFG_INTERFACE_IRQPORT, CFG_INTERFACE_IRQPIN, gpioDirection_Output); gpioSetValue(CFG_INTERFACE_IRQPORT, CFG_INTERFACE_IRQPIN, 1); #endif // init the msg ptr msg_ptr = msg; // Show the menu cmdMenu(); // Set the IRQ pin low by default #if CFG_INTERFACE_ENABLEIRQ != 0 gpioSetValue(CFG_INTERFACE_IRQPORT, CFG_INTERFACE_IRQPIN, 0); #endif }
int main(void) { // Configure cpu and mandatory peripherals systemInit(); // Make sure that projectconfig.h is properly configured for this example #if !defined CFG_CHIBI #error "CFG_CHIBI must be enabled in projectconfig.h for this example" #endif #if CFG_CHIBI_PROMISCUOUS != 0 #error "CFG_CHIBI_PROMISCUOUS must be set to 0 in projectconfig.h for this example" #endif #ifdef CFG_CHIBI uint32_t counter = 0; chb_pcb_t *pcb = chb_get_pcb(); while(1) { // Enable LED gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); // Create and send the message char text[10]; counter++; itoa(counter, text, 10); chb_write(0xFFFF, text, strlen(text) + 1); // Disable LED gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); systickDelay(250); } #endif return 0; }
void cmd_chibi_tx(uint8_t argc, char **argv) { uint8_t i, len, *data_ptr, data[50]; uint16_t addr; // Try to convert supplied address to an integer int32_t addr32; getNumber (argv[0], &addr32); // Check for invalid values (getNumber may complain about this as well) if (addr32 <= 0 || addr32 > 0xFFFF) { printf("Invalid Address: 1-65534 or 0x0001-0xFFFE required.%s", CFG_PRINTF_NEWLINE); return; } // Address seems to be OK addr = (uint16_t)addr32; // Get message contents data_ptr = data; for (i=0; i<argc-1; i++) { len = strlen(argv[i+1]); strcpy((char *)data_ptr, (char *)argv[i+1]); data_ptr += len; *data_ptr++ = ' '; } *data_ptr++ = '\0'; // Send message gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); chb_write(addr, data, data_ptr - data); gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); }
void tsReadZ(uint32_t* z1, uint32_t* z2) { if (!_tsInitialised) tsInit(); // Make sure that X+/Y- are set to GPIO TS_XP_FUNC_GPIO; TS_YM_FUNC_GPIO; // Set X- and Y+ to inputs (necessary?) gpioSetDir (TS_XM_PORT, TS_XM_PIN, 0); gpioSetDir (TS_YP_PORT, TS_YP_PIN, 0); // Set X+ and Y- to output gpioSetDir (TS_XP_PORT, TS_XP_PIN, 1); gpioSetDir (TS_YM_PORT, TS_YM_PIN, 1); // X+ goes low, Y- goes high gpioSetValue(TS_XP_PORT, TS_XP_PIN, 0); // GND gpioSetValue(TS_YM_PORT, TS_YM_PIN, 1); // 3.3V // Set X- and Y+ to ADC TS_XM_FUNC_ADC; TS_YP_FUNC_ADC; // Get ADC results *z1 = adcRead(TS_YP_ADC_CHANNEL); // Z1 (Read Y+) *z2 = adcRead(TS_XM_ADC_CHANNEL); // Z2 (Read X-) }
int main () { init (); gpioSetDir (3, 1, 1); gpioSetValue (3, 1, 1); int availBytes; char buf[32]; uint8_t frame[64]; for (int i = 0; i < 64; ++i) { frame[i] = i; } while (1) { systickDelay (1); USB_WriteEP (CDC_DEP_IN, frame, 64); // CDC_WrOutBuf (text, &textLen); CDC_OutBufAvailChar (&availBytes); if (availBytes > 0) { int bytesToRead = availBytes > 32 ? 32 : availBytes; int bytesRead = CDC_RdOutBuf (buf, &bytesToRead); gpioSetValue (3, 1, 0); } } }
void samsungvfdWrite(uint8_t value) { gpioSetValue(SAMSUNGVFD_STB_PORT, SAMSUNGVFD_STB_PIN, 0); samsungvfd_sendByte(SAMSUNGVFD_SPIDATA); samsungvfd_sendByte(value); gpioSetValue(SAMSUNGVFD_STB_PORT, SAMSUNGVFD_STB_PIN, 1); }
void avrspi_tx(uint8_t byteToSend) { uint8_t spiBuf = byteToSend; gpioSetValue(RB_LED0, 1); sspSend(0, (uint8_t *)&spiBuf, 1); gpioSetValue(RB_LED0, 0); }
void tsReadZ(uint32_t* z1, uint32_t* z2) { if (!_tsInitialised) tsInit(); // XP = ADC // XM = GPIO Output Low // YP = GPIO Output High // YM = GPIO Input TS_XM_FUNC_GPIO; TS_YP_FUNC_GPIO; TS_YM_FUNC_GPIO; gpioSetDir (TS_XM_PORT, TS_XM_PIN, 1); gpioSetDir (TS_YP_PORT, TS_YP_PIN, 1); gpioSetDir (TS_YM_PORT, TS_YM_PIN, 0); gpioSetValue(TS_XM_PORT, TS_XM_PIN, 0); // GND gpioSetValue(TS_YP_PORT, TS_YP_PIN, 1); // 3.3V TS_XP_FUNC_ADC; *z1 = adcRead(TS_XP_ADC_CHANNEL); // XP = GPIO Input // XM = GPIO Output Low // YP = GPIO Output High // YM = ADC TS_XP_FUNC_GPIO; gpioSetDir (TS_YM_PORT, TS_YM_PIN, 0); TS_YM_FUNC_ADC; *z2 = adcRead(TS_YM_ADC_CHANNEL); }
uint32_t tsReadY(void) { if (!_tsInitialised) tsInit(); // YP = GPIO Output High // YM = GPIO Output Low // XP = GPIO Input // XM = ADC TS_YP_FUNC_GPIO; TS_YM_FUNC_GPIO; TS_XP_FUNC_GPIO; gpioSetDir (TS_YP_PORT, TS_YP_PIN, 1); gpioSetDir (TS_YM_PORT, TS_YM_PIN, 1); gpioSetDir (TS_XP_PORT, TS_XP_PIN, 0); gpioSetValue(TS_YP_PORT, TS_YP_PIN, 1); // 3.3V gpioSetValue(TS_YM_PORT, TS_YM_PIN, 0); // GND TS_XM_FUNC_ADC; // Return the ADC results return adcRead(TS_XM_ADC_CHANNEL); }
void samsungvfd_command(uint8_t value) { gpioSetValue(SAMSUNGVFD_STB_PORT, SAMSUNGVFD_STB_PIN, 0); samsungvfd_sendByte(SAMSUNGVFD_SPICOMMAND); samsungvfd_sendByte(value); gpioSetValue(SAMSUNGVFD_STB_PORT, SAMSUNGVFD_STB_PIN, 1); }
void cmdParse(char *cmd) { size_t argc, i = 0; char *argv[30]; argv[i] = strtok(cmd, " "); do { argv[++i] = strtok(NULL, " "); } while ((i < 30) && (argv[i] != NULL)); argc = i; for (i=0; i < CMD_COUNT; i++) { if (!strcmp(argv[0], cmd_tbl[i].command)) { if ((argc == 2) && !strcmp (argv [1], "?")) { // Display parameter help menu on 'command ?' printf ("%s%s%s", cmd_tbl[i].description, CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE); printf ("%s%s", cmd_tbl[i].parameters, CFG_PRINTF_NEWLINE); } else if ((argc - 1) < cmd_tbl[i].minArgs) { // Too few arguments supplied printf ("Too few arguments (%d expected)%s", cmd_tbl[i].minArgs, CFG_PRINTF_NEWLINE); printf ("%sType '%s ?' for more information%s%s", CFG_PRINTF_NEWLINE, cmd_tbl[i].command, CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE); } else if ((argc - 1) > cmd_tbl[i].maxArgs) { // Too many arguments supplied printf ("Too many arguments (%d maximum)%s", cmd_tbl[i].maxArgs, CFG_PRINTF_NEWLINE); printf ("%sType '%s ?' for more information%s%s", CFG_PRINTF_NEWLINE, cmd_tbl[i].command, CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE); } else { #if CFG_INTERFACE_ENABLEIRQ != 0 // Set the IRQ pin high at start of a command gpioSetValue(CFG_INTERFACE_IRQPORT, CFG_INTERFACE_IRQPIN, 1); #endif // Dispatch command to the appropriate function cmd_tbl[i].func(argc - 1, &argv [1]); #if CFG_INTERFACE_ENABLEIRQ != 0 // Set the IRQ pin low to signal the end of a command gpioSetValue(CFG_INTERFACE_IRQPORT, CFG_INTERFACE_IRQPIN, 0); #endif } // Refresh the command prompt cmdMenu(); return; } } printf("Command not recognized: '%s'%s%s", cmd, CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE); #if CFG_INTERFACE_SILENTMODE == 0 printf("Type '?' for a list of all available commands%s", CFG_PRINTF_NEWLINE); #endif cmdMenu(); }
void chb_drvr_init() { // ToDo: Make sure gpioInit has been called // ToDo: Make sure CT32B0 has been initialised and enabled // config SPI for at86rf230 access chb_spi_init(); // Setup 16-bit timer 0 (used for us delays) timer16Init(0, 0xFFFF); timer16Enable(0); // Set sleep and reset as output gpioSetDir(CHB_SLPTRPORT, CHB_SLPTRPIN, 1); gpioSetDir(CHB_RSTPORT, CHB_RSTPIN, 1); // configure IOs gpioSetValue(CHB_SLPTRPORT, CHB_SLPTRPIN, 1); // Set sleep high gpioSetValue(CHB_RSTPORT, CHB_RSTPIN, 1); // Set reset high // Set internal resistors gpioSetPullup (&CHB_SLPTRPIN_IOCONREG, gpioPullupMode_Inactive); gpioSetPullup (&CHB_RSTPIN_IOCONREG, gpioPullupMode_Inactive); // config radio chb_radio_init(); }
// let the robot stop // usage: go_stop() int go_stop(void) { gpioSetValue(OUT1, off); gpioSetValue(OUT2, off); gpioSetValue(OUT3, off); gpioSetValue(OUT4, off); return 0; }
/** reaction.c * First l0dable for my r0ket * Improvement is welcome * * AUTHOR: hubba */ void ram(void) { char x = gpioGetValue(RB_LED1); int rand_wait = 0; int react_time=0; int start_time = 0; int end_time = 0; gpioSetValue (RB_LED1,0); //upperleft LED off lcdClear(); lcdPrintln("Hello"); lcdPrintln(GLOBAL(nickname)); lcdPrintln("ReACTION"); lcdRefresh(); delayms(500); while(1) { react_time = 0; lcdPrintln("Press ENTER if "); lcdPrintln("LED is on!"); lcdRefresh(); rand_wait = getRandom(); rand_wait = rand_wait%50; rand_wait = 40 + rand_wait*4; // Minimum pause time is 400ms for(int i =0; i<=rand_wait; i++) //directly calling delayms(rand_wait) didn't work { delayms(10); } gpioSetValue (RB_LED1, 1); //upperleft LED ON getInputWaitRelease(); start_time = getTimer()*(SYSTICKSPEED); while (getInputWait() != BTN_ENTER); //wait for user input { } end_time = getTimer()*(SYSTICKSPEED); react_time = end_time - start_time; //measure used time lcdClear(); lcdPrint("Needed "); lcdPrintInt(react_time); lcdPrintln(" ms"); lcdPrintln("DOWN: Exit"); lcdPrintln("0ther: New game"); lcdRefresh(); gpioSetValue (RB_LED1,0); //upperleft LED off getInputWaitRelease(); if(getInputWait() == BTN_DOWN) //Check for Exit/new game { gpioSetValue (RB_LED1, x); //upperleft LED as before l0dable executed return; } } /* NEVER LAND HERE */ lcdPrintln("Flow-Error"); lcdRefresh(); return; };
uint8_t avrspi_rx(void) { uint8_t spiBuf; gpioSetValue(RB_LED2, 1); sspReceive(0, (uint8_t *)&spiBuf, 1); gpioSetValue(RB_LED2, 0); return spiBuf; }
void ram(void){ char x = gpioGetValue(RB_LED1); for (int x=0;x<20;x++){ gpioSetValue (RB_LED1, x%2); delayms(50); }; gpioSetValue (RB_LED1, x); }
uint32_t tsReadY(void) { if (!_tsInitialised) tsInit(); lcdOrientation_t orientation; orientation = lcdGetOrientation(); if (orientation == LCD_ORIENTATION_LANDSCAPE) { // Make sure Y+/Y- are set to GPIO TS_YP_FUNC_GPIO; TS_YM_FUNC_GPIO; // Set X- and X+ to inputs gpioSetDir (TS_XM_PORT, TS_XM_PIN, 0); gpioSetDir (TS_XP_PORT, TS_XP_PIN, 0); // Set Y- and Y+ to output gpioSetDir (TS_YM_PORT, TS_YM_PIN, 1); gpioSetDir (TS_YP_PORT, TS_YP_PIN, 1); // Y+ goes high, Y- goes low gpioSetValue(TS_YP_PORT, TS_YP_PIN, 1); // 3.3V gpioSetValue(TS_YM_PORT, TS_YM_PIN, 0); // GND // Set pin 1.0 (X+) to ADC1 TS_XP_FUNC_ADC; // Return the ADC results return adcRead(TS_XP_ADC_CHANNEL); } else { // Make sure X+/X- are set to GPIO TS_XP_FUNC_GPIO; TS_XM_FUNC_GPIO; // Set Y- and Y+ to inputs gpioSetDir (TS_YM_PORT, TS_YM_PIN, 0); gpioSetDir (TS_YP_PORT, TS_YP_PIN, 0); // Set X- and X+ to output gpioSetDir (TS_XM_PORT, TS_XM_PIN, 1); gpioSetDir (TS_XP_PORT, TS_XP_PIN, 1); // X+ goes high, X- goes low gpioSetValue(TS_XP_PORT, TS_XP_PIN, 1); // 3.3V gpioSetValue(TS_XM_PORT, TS_XM_PIN, 0); // GND // Set pin 0.11 (Y+) to ADC0 TS_YP_FUNC_ADC; // Return the ADC results return adcRead(TS_YP_ADC_CHANNEL); } }
void samsungvfdWriteString(const char * str) { while(*str) { gpioSetValue(SAMSUNGVFD_STB_PORT, SAMSUNGVFD_STB_PIN, 0); samsungvfd_sendByte(SAMSUNGVFD_SPIDATA); samsungvfd_sendByte(*str++); gpioSetValue(SAMSUNGVFD_STB_PORT, SAMSUNGVFD_STB_PIN, 1); } }
static portTASK_FUNCTION(leduj2, pvParameters) { while(1) { vTaskDelay(600/portTICK_RATE_MS); gpioSetValue(2, 2, 1); vTaskDelay(600/portTICK_RATE_MS); gpioSetValue(2, 2, 0); } }
int main(void) { // Configure cpu and mandatory peripherals systemInit(); // Check if projectconfig.h is properly configured for this example #if !defined CFG_CHIBI #error "CFG_CHIBI must be enabled in projectconfig.h for this example" #endif #if CFG_CHIBI_PROMISCUOUS == 0 #error "CFG_CHIBI_PROMISCUOUS must set to 1 in projectconfig.h for this example" #endif #if !defined CFG_PRINTF_UART #error "CFG_PRINTF_UART must be enabled in projectconfig.h for this example" #endif #if defined CFG_INTERFACE #error "CFG_INTERFACE must be disabled in projectconfig.h for this example" #endif #if defined CFG_CHIBI && CFG_CHIBI_PROMISCUOUS != 0 // Get a reference to the Chibi peripheral control block chb_pcb_t *pcb = chb_get_pcb(); // Wait for incoming frames and transmit the raw data over uart while(1) { // Check for incoming messages while (pcb->data_rcv) { // get the length of the data rx_data.len = chb_read(&rx_data); // make sure the length is nonzero if (rx_data.len) { // Enable LED to indicate message reception gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); // Send raw data to UART for processing on // the PC (requires WSBridge - www.freaklabs.org) uint8_t i; for (i=0; i<rx_data.len; i++) { // Send output to UART uartSendByte(rx_data.data[i]); } // Disable LED gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); } } } #endif return 0; }
void chb_set_hgm(U8 enb) { if (enb) { gpioSetValue(CHB_CC1190_HGM_PORT, CHB_CC1190_HGM_PIN, 1); } else { gpioSetValue(CHB_CC1190_HGM_PORT, CHB_CC1190_HGM_PIN, 0); } }
int main(void) { #ifndef CFG_PWM #ERROR "CFG_PWM must be enabled in projectconfig.h for this example." #endif // Configure cpu and mandatory peripherals // PWM is initialised in systemInit and defaults to using P1.9 systemInit(); // Set duty cycle to 50% for square wave output pwmSetDutyCycle(50); // Frequency can be set anywhere from 2khz and 10khz (4khz is loudest) // Note: Since this is a 16-bit timer, make sure the delay is not // greater than 0xFFFF (65535), though anything 2khz and higher // is within an acceptable range // The piezo buzzer used for this example is the PS1240, available at // http://www.adafruit.com/index.php?main_page=product_info&cPath=35&products_id=160 pwmSetFrequencyInTicks(CFG_CPU_CCLK / 2000); uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; while (1) { // Beep the piezo buzzer very briefly once per second, toggling the LED at the same time currentSecond = systickGetSecondsActive(); // Make sure that at least one second has passed if (currentSecond != lastSecond) { // Update the second tracker lastSecond = currentSecond; // Set the LED state and buzzer loudness depending on the current LED state if (gpioGetValue(CFG_LED_PORT, CFG_LED_PIN) == CFG_LED_OFF) { pwmSetFrequencyInTicks(CFG_CPU_CCLK / 4000); // 4khz (louder) pwmStartFixed(200); // 2x as long as @ 2khz since it's 2x faster gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); // Turn the LED on } else { pwmSetFrequencyInTicks(CFG_CPU_CCLK / 2000); // 2khz (softer) pwmStartFixed(100); gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); // Turn the LED off } } } return 0; }
void samsungvfdInit(uint8_t brightness) { // Set all pins to output gpioSetDir(SAMSUNGVFD_SIO_PORT, SAMSUNGVFD_SIO_PIN, gpioDirection_Output); gpioSetDir(SAMSUNGVFD_STB_PORT, SAMSUNGVFD_STB_PIN, gpioDirection_Output); gpioSetDir(SAMSUNGVFD_SCK_PORT, SAMSUNGVFD_SCK_PIN, gpioDirection_Output); // Set strobe and clock pins high by default gpioSetValue(SAMSUNGVFD_STB_PORT, SAMSUNGVFD_STB_PIN, 1); gpioSetValue(SAMSUNGVFD_SCK_PORT, SAMSUNGVFD_SCK_PIN, 1); // Default to 2x20 display (SAMSUNG 20T202DA2JA) samsungvfd_begin(20, 2, brightness); }
void PIOINT0_IRQHandler(void) { uint32_t regVal; #ifdef CFG_BRD_LPC1343_ARMBY regVal = gpioIntStatus(CFG_PB_PORT, CFG_PB_PIN); if (regVal) { gpioIntClear(CFG_PB_PORT, CFG_PB_PIN); gpioSetValue(CFG_PB_PORT,CFG_PB_PIN,0); // turn off gpioSetValue(CFG_REGEN_PORT,CFG_REGEN_PIN,0); // turn off } #endif return; }
int main(void) { // Configure cpu and mandatory peripherals systemInit(); uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; // uartInit(115200); prt(); while (1) { // Toggle LED once per second currentSecond = systickGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, !(gpioGetValue(CFG_LED_PORT, CFG_LED_PIN))); uartSendByte('*'); } // Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h #ifdef CFG_INTERFACE cmdPoll(); #endif } return 0; }
// Grabs line sensor data using i2c and dumps into LineSensor array. // Returns 1 if successful, 0 if encountered a timeout error // (timeout probably means the line sensor isn't connected correctly) int readLineSensor(int LineSensor[8]) { int i; char cmd; gpioSetValue(2, 10, 1); for(i=0; i<8; i++) //clear i2c buffers { I2CMasterBuffer[i] = 0; I2CSlaveBuffer[i] = 0; } cmd = 0x84; //1 CH# 01 XX for request conversion. e.g 1 000 01 00 is for channel 2 for(i=0; i<8; i++) { ////printf("Reading channel %d\n\r", i); I2CWriteLength = 2; I2CReadLength = 1; I2CMasterBuffer[0] = ADS7830_ADDR; I2CMasterBuffer[1] = cmd; cmd += 0x10; //increment channel I2CMasterBuffer[2] = ADS7830_ADDR | READ_BIT; //not included in writelength b/c its a repeated start int timeout = i2cEngine(); //run the transaction and waits for value to be read back if (timeout > MAX_TIMEOUT) { //printf("ERROR: timeout (device not connected correctly)\n\r"); return 0; } LineSensor[i] = I2CSlaveBuffer[0]; //> 100 ? 999 : 0; //sadly after each transaction the RdIndex is returned to 0, could change i2c driver... } return 1; }
void ram() { char *nick = "Pentagon V1LLAG3"; char nickbuf[32]; // 16? do { lcdFill(0); DoString(0, 0, "Getting"); lcdDisplay(); uint32_t score = highscore_get(nickbuf); gpioSetValue (RB_LED2, 1); lcdFill(0); DoString(0, 0, "Highscore:"); DoString(0, 16, nickbuf); DoInt(0, 32, score); lcdDisplay(); if (strcmp(nick, nickbuf) != 0) { lcdFill(0); DoString(0, 48, "Setting"); lcdDisplay(); delayms_queue(500); highscore_set(score+1, nick); } } while(getInputWaitTimeout(500) != BTN_UP); }
void usbHIDSetOutReport (uint8_t dst[], uint32_t length) { uint8_t PCOutReportData = dst[0]; // Check bit 0 in the incoming report to determine is LED should // be enabled or disabled (1 = enabled, 0 = disabled) if (PCOutReportData & (1<<0)) { // Enable LED (set low) gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, 0); } else { // Disable LED (set high) gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, 1); } }
void VoltageCheck(void){ chrg=gpioGetValue(RB_PWR_CHRG); results = adcRead(1); results *= 10560; results /= 1024; if( results < 3500 ){ nrf_off(); gpioSetValue (RB_PWR_GOOD, 0); gpioSetValue (RB_LCD_BL, 0); SCB_SCR |= SCB_SCR_SLEEPDEEP; PMU_PMUCTRL = PMU_PMUCTRL_DPDEN_DEEPPOWERDOWN; __asm volatile ("WFI"); };