int main() { // Set the clocking to run directly from the crystal. SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // Initialize the OLED display. RIT128x96x4Init(1000000); //Initializes the LED needed for the blinking-sensor part of the assignment //Initializes the ADC ADCInit(); //Initializes the keys on the keypad on the Stellaris Board key_init(); //Initializes Timer0 and enables Timer0 interrupts timer0_init(); //Initializes GPIO PORT E and enables its interrupts init_GPIOE(); //Initializes GPIO PORT F and enables its interrupts init_GPIOF(); // main loop while(TRUE) { // if (keymaster()) { // RIT128x96x4StringDraw("HELLO\0", 30, 24, 15); // } else { // RIT128x96x4StringDraw("YOLLO\0", 30, 24, 15); // } } }
static void prvSetupHardware( void ) { SystemCoreClockUpdate(); // enable clock to RAM1 LPC_SYSCON->SYSAHBCLKCTRL |= (1<<26); // init GPIO GPIOInit(); // init I2C I2CInit(I2CMASTER); //init ADC ADCInit(ADC_CLK); // init SPI ports SSP_IOConfig( 0 ); SSP_Init( 0 ); SSP_IOConfig( 1 ); SSP_Init( 1 ); // init keyboard CAP_KEY_Init(); // init MOSFET pin LPC_IOCON->PIO1_25=0x90; GPIOSetDir(PIN_MOSFET,1); }
/***************************************************************************** ** Main Function main() ******************************************************************************/ int main (void) { /* SystemClockUpdate() updates the SystemFrequency variable */ SystemClockUpdate(); /* Initialize ADC */ ADCInit( ADC_CLK ); while(1) { #if BURST_MODE /* Interrupt driven only */ ADCBurstRead(); while ( !ADCIntDone ); ADCIntDone = 0; if ( OverRunCounter != 0 ) { while ( 1 ); } #else /* Not burst mode */ #if ADC_INTERRUPT_FLAG /* Interrupt driven */ for ( i = 0; i < ADC_NUM; i++ ) { ADCRead( i ); while ( !ADCIntDone ); ADCIntDone = 0; } #else /* Polling */ for ( i = 0; i < ADC_NUM; i++ ) { ADCValue[i] = ADCRead( i ); } #endif /* Endif interrupt driven */ #endif /* Endif BURST mode */ } }
// This function initializes all hardware used by our system. void InitializeHardware() { RIT128x96x4Init(1000000); //Initializes the LED //LED_init(); //Initializes the ADC ADCInit(); //Initializes the keys on the keypad on the Stellaris Board key_init(); //Initializes GPIO PORT E and enables its interrupts init_GPIOE(); //Initializes GPIO PORT F and enables its interrupts init_GPIOF(); // Initializes the PWM's used PWMinit(); // Initializes Port D to use for sending signals to the H-bridge PORTD_init(); PORTC_init(); // This method is used by FreeRtos prvSetupHardware(); // This initializes the speaker speakerInit(); //Sets the UART port uARTInit(); }
void main(void) { //Initialize the LCD module LCDInit(LS_NONE); //Initialize the ADC module ADCInit(); //Clear the LCD LCDClear(); LCDWriteString("Thermometer"); while(1) { //Read the temperature using LM35 float t = LM35ReadTemp(); //Print it on the LCD LCDWriteIntXY(0,1,t,3); //Print the degree symbol and C LCDWriteString("%0C"); //Wait 200ms before taking next reading __delay_ms(200); } }
void main() { unsigned int adc_xval,adc_yval,adc_zval; ADCInit(); lcd_init(); while(1) { adc_xval=adcRead(0); lcd_gotoxy1(1); lcd_showvalue(adc_xval); adc_yval=adcRead(1); lcd_gotoxy1(4); lcd_showvalue(adc_yval); adc_zval=adcRead(2); lcd_gotoxy1(7); lcd_showvalue(adc_zval); } }
void pixyInit(uint32_t slaveRomStart, const unsigned char slaveImage[], uint32_t imageSize) { // write stack guard word STACK_GUARD = STACK_GUARD_WORD; commonInit(); IPC_haltSlave(); ADCInit(); SCTInit(); CameraInit(); // start slave if (slaveRomStart && slaveImage && imageSize) { IPC_downloadSlaveImage(slaveRomStart, slaveImage, imageSize); IPC_startSlave(); } // initialize chirp objects USBLink *usbLink = new USBLink; g_chirpUsb = new Chirp(false, false, usbLink); SMLink *smLink = new SMLink; g_chirpM0 = new Chirp(false, true, smLink); // initialize devices/modules led_init(); if (prm_init(g_chirpUsb)<0) // error, let user know (don't just continue like nothing's happened) showError(1, 0x0000ff, "Flash is corrupt, parameters have been lost\n"); pwr_init(); cam_init(); rcs_init(); //cc_init(); }
//Function to configure ADC Channels, PWM Channels and GPIO pins for DOF1 Control void robot_setconfig() { //UART_Init(0,9600); ADCInit(ADC_CLK); PWMInit(); GPIOInit(); }
int main(void) { //GPIOInit(); SysTick_Config( SystemCoreClock/1000 ); SysTick->CTRL &= (0 << 1); //initDrive(); ADCInit( ADC_CLK ); //initReflex(); //GPIOSetDir( 3, 2, 1 ); //GPIOSetValue( 3, 2, 0); GPIOSetDir( LED_PORT, LED_BIT, 1 ); GPIOSetValue( LED_PORT, LED_BIT, LED_OFF ); GPIOSetDir( 3, 2, 1 ); // Enter an infinite loop, just incrementing a counter volatile static int i = 0 ; while(1) { //uint16_t adcValue = ADCRead( 5 ); if(reflexRead())//adcValue > 100) { GPIOSetValue( LED_PORT, LED_BIT, LED_ON ); } else { GPIOSetValue( LED_PORT, LED_BIT, LED_OFF ); } //i++; } return 0 ; }
void setup_ports(void) { /* Initialize GPIO_ (sets up clock) */ GPIO_Init(); scandal_init(); UART_Init(UART_CLK); ADCInit(ADC_CLKSCALE); GPIO_SetDir(ID_PORT, ID0_BIT, INPUT); GPIO_SetDir(ID_PORT, ID1_BIT, INPUT); GPIO_SetDir(ID_PORT, ID2_BIT, INPUT); GPIO_SetDir(ID_PORT, ID3_BIT, INPUT); GPIO_SetDir(ID_PORT, ID4_BIT, INPUT); GPIO_SetDir(ID_PORT, ID5_BIT, INPUT); GPIO_SetDir(BURSTMODE_PORT, BURSTMODE_BIT, OUTPUT); GPIO_SetDir(CAN_EN_PORT, CAN_EN_BIT, OUTPUT); GPIO_SetDir(DISCHARGE_PORT, DISCHARGE_BIT, OUTPUT); GPIO_SetValue(DISCHARGE_PORT, DISCHARGE_BIT, OFF); GPIO_SetDir(VOLT_SENSE_EN_PORT, VOLT_SENSE_EN_BIT, OUTPUT); GPIO_SetDir(TEMP_SENSE_EN_PORT, TEMP_SENSE_EN_BIT, OUTPUT); GPIO_SetDir(YELLOW_LED_PORT, YELLOW_LED_BIT, OUTPUT); GPIO_SetDir(RED_LED_PORT, RED_LED_BIT, OUTPUT); GPIO_SetDir(WAKEUP_PORT, WAKEUP_BIT, INPUT); //delay for time, or perhaps should specify a voltage to discharge to? }
/** * @brief Sets up the hardware. * * - Starts the clock at 48MHz with the PLL * - Starts the MAM (Memory accelerator module) for faster reads and writes * - Initialize the LED outputs * - Initialize the PWM outputs * - Initialize the ADC inputs * - Initialize the LCD outputs * - Start the ROS and Debug serial ports */ static void prvSetupHardware( void ) { #ifdef RUN_FROM_RAM /* Remap the interrupt vectors to RAM if we are are running from RAM. */ SCB_MEMMAP = 2; #endif /* Disable the PLL. */ PLLCON = 0; PLLFEED = mainPLL_FEED_BYTE1; PLLFEED = mainPLL_FEED_BYTE2; /* Configure clock source. */ SCS |= mainOSC_ENABLE; while( !( SCS & mainOSC_STAT ) ); CLKSRCSEL = mainOSC_SELECT; /* Setup the PLL to multiply the XTAL input by 4. */ PLLCFG = ( mainPLL_MUL | mainPLL_DIV ); PLLFEED = mainPLL_FEED_BYTE1; PLLFEED = mainPLL_FEED_BYTE2; /* Turn on and wait for the PLL to lock... */ PLLCON = mainPLL_ENABLE; PLLFEED = mainPLL_FEED_BYTE1; PLLFEED = mainPLL_FEED_BYTE2; CCLKCFG = mainCPU_CLK_DIV; while( !( PLLSTAT & mainPLL_LOCK ) ); /* Connecting the clock. */ PLLCON = mainPLL_CONNECT; PLLFEED = mainPLL_FEED_BYTE1; PLLFEED = mainPLL_FEED_BYTE2; while( !( PLLSTAT & mainPLL_CONNECTED ) ); /* This code is commented out as the MAM does not work on the original revision LPC2368 chips. If using Rev B chips then you can increase the speed though the use of the MAM. Setup and turn on the MAM. Three cycle access is used due to the fast PLL used. It is possible faster overall performance could be obtained by tuning the MAM and PLL settings. */ MAMCR = 0; MAMTIM = mainMAM_TIM_3; MAMCR = mainMAM_MODE_FULL; /* Setup the led's on the MCB2300 board */ vParTestInitialise(); PWMInit(); ADCInit(); LcdInit(); IOInit(); rosPortHandle = xSerialPortInit( serCOM1, ser57600, serNO_PARITY, serBITS_8, serSTOP_1, 1000 ); //debugPortHandle = xSerialPortInit( serCOM2, ser57600, serNO_PARITY, serBITS_8, // serSTOP_1, 250 ); }
int main(void) { //******************************************************************* Init(); TMRInit(2); // Initialize Timer interface with Priority=2 BLIInit(); // Initialize Signal interface ADCInit(3); // Initialize ADC UARTInitTX(6, 350); // Initialize UART1 for TX // This initialization routine accepts BaudRate in multiples // of 2400 bps; Thus: // BaudRate = 1 => 2400 bps // BaudRate = 2 => 4800 bps // ... // BaudRate = 48 => 115200 bps //------------------------------------------------------------ // High speed //------------------------------------------------------------ // BaudRate = 100 => 250,000 bps // BaudRate = 200 => 500,000 bps // BaudRate = 250 => 625,000 bps // BaudRate = 350 => 833,333 bps // BaudRate = 500 => 1,250,000 bps // BaudRate = 1000 => 2,500,000 bps //******************************************************************* struct { float V; uint Raw; uint Stat; } UData; int i = 0; int j = 0; BLISignalON(); while(j < 10) { TMRDelay(10); //-------------------------- UData.V = ADCGetBatteryVoltage(); UData.Raw = ADCGetRawSample(); UData.Stat = ADCGetBatteryStatus(); //-------------------------- UARTPostWhenReady((uchar*)&UData, sizeof(UData)); i++; //-------------------------- if (i >= 100) { UARTPostWhenReady(NULL, 0); BLISignalFlip(); //------------------------ i = 0; j++; } TMRDelay(10); } return 1; }
int main (void) { uint32_t analogValue; //Set segment A-G+DP pins as outputs GPIOSetDir( SEG_A_PORT, SEG_A_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_A_PORT, SEG_A_PIN, LED_OFF); GPIOSetDir( SEG_B_PORT, SEG_B_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_B_PORT, SEG_B_PIN, LED_OFF); GPIOSetDir( SEG_C_PORT, SEG_C_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_C_PORT, SEG_C_PIN, LED_OFF); GPIOSetDir( SEG_D_PORT, SEG_D_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_D_PORT, SEG_D_PIN, LED_OFF); GPIOSetDir( SEG_E_PORT, SEG_E_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_E_PORT, SEG_E_PIN, LED_OFF); GPIOSetDir( SEG_F_PORT, SEG_F_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_F_PORT, SEG_F_PIN, LED_OFF); GPIOSetDir( SEG_G_PORT, SEG_G_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_G_PORT, SEG_G_PIN, LED_OFF); GPIOSetDir( SEG_DP_PORT, SEG_DP_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_DP_PORT, SEG_DP_PIN, LED_OFF); GPIOSetDir( DIG1_PORT, DIG1_PIN, GPIO_OUTPUT); GPIOSetValue( DIG1_PORT, DIG1_PIN, 1); GPIOSetDir( DIG2_PORT, DIG2_PIN, GPIO_OUTPUT); GPIOSetValue( DIG2_PORT, DIG2_PIN, 1); //Set SW2/SW3 pins as inputs GPIOSetDir( SW2_PORT, SW2_PIN, GPIO_INPUT); GPIOSetDir( SW3_PORT, SW3_PIN, GPIO_INPUT); //Extra, turn buzzer off GPIOSetDir( BUZZ_PORT, BUZZ_PIN, GPIO_OUTPUT); GPIOSetValue( BUZZ_PORT, BUZZ_PIN, BUZZ_OFF); //Initialize ADC peripheral and pin-mixing ADCInit(4500000); //4.5MHz ADC clock //get initial value analogValue = getADC(AIN0); //AIN0 = trimming pot for intensity while(1) { uint8_t outputValue; outputValue = convert00_99(getADC(AIN0)); GPIOSetValue( DIG1_PORT, DIG1_PIN, 1); GPIOSetValue( DIG2_PORT, DIG2_PIN, 0); setSegment(outputValue / 10); delayMS(10); GPIOSetValue( DIG2_PORT, DIG2_PIN, 1); GPIOSetValue( DIG1_PORT, DIG1_PIN, 0); setSegment(outputValue % 10); delayMS(10); } return 0; }
void main() { union { unsigned int32 hours; unsigned int8 minutes; unsigned int8 seconds;} upTime; TICK_TYPE CurrentTick,PreviousUDPTick,PreviousSATick; resetStatus = (RCON & 0b00111111) | !(STKPTR & 0b11000000); // Get the Reset Status RCON = RCON | 0b00111111; //Reset RCON Reset flags... (Reset Register) STKPTR = STKPTR & 0b00111111; // Clear Stack Overflow/Underflow flags PortInit(); OutputInit(); restart_wdt(); romEZHRInit(); //set up default ezhr settings eeROMinit(); //set up default eprom settings IPAddressInit(); //set up MAC and default IP addresses delay_ms(500); ADCInit(); //set up ADC ports iniADCParams(); SerialInit(); //set up serial ports TickInit(); //set up tick timer enable_interrupts(INT_RDA); enable_interrupts(GLOBAL); StackInit(); WritePHYReg(ERXFCON,EthernetRXfilterSetting); // Allow only uni & multi SetLEDConfig(E_LED_CONFIG); // swap LED's output_high(E_SW_PWR_DN); // Power Ethernet Switch output_high(E_SW_RST); output_low(RS485_TXEN); output_high(RS485_RXDIS); output_high(RS232_F_OFF); output_high(RS232_F_ON); CurrentTick = PreviousUDPTick = get_ticks(); UDPSampleRate = eeReadUDPRate() * TICKS_PER_MILLISECOND; portControlInit(); while(TRUE) { CurrentTick = get_ticks(); restart_wdt(); StackTask(); restart_wdt(); MyTCPTask();//handles TCP connections restart_wdt(); setIO();// checks voltage status and sets ports accordingly //! if(CurrentTick-PreviousUDPTick >= UDPSampleRate) //! { //! currentRoutine=UDPTASK; //! BOOL UDPDone = MyUDPTask(); //! if(UDPDone) //! { //! PreviousUDPTick=CurrentTick; //! } //! } StackApplications(); } }
void initAnalog(void) { static uint8_t runOnce = 0; if (!runOnce) { runOnce = 1; ADCInit(); ADCSetRef(AVCC); ADCSetPrescale(ADC_PRESCALE_DIV128); } }
int main(void) { GPIOInit(); ADCInit(); while(1) { value = ReadADC1(1) * 0.0822 * 2.54; } }
void Board::init() // initialize the board specifics { // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // ROM_FPULazyStackingEnable(); // // Set the clocking to run from the PLL at 50MHz // ROM_SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); Usb::init(); /* // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. FPUEnable(); FPULazyStackingEnable(); SysCtlClockSet( SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // Set the clocking to run directly from the crystal. IntMasterEnable(); // Enable interrupts to the processor.*/ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Enable the GPIO port that is used for the on-board LED. GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); // Enable the GPIO pins for the LED (PF2). GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3); /* SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // Enable the peripherals used by this example. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); IntMasterEnable(); // Enable processor interrupts. // Set up the period for the SysTick timer for 1 mS. SysTickPeriodSet(SysCtlClockGet() / 1000); SysTickIntEnable(); // Enable the SysTick Interrupt. SysTickEnable(); // Enable SysTick. GPIOPinConfigure(GPIO_PA0_U0RX); // Set GPIO A0 and A1 as UART pins. GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // Configure the UART for 115,200, 8-N-1 operation. IntEnable(INT_UART0); UARTFIFODisable(UART0_BASE); // UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); UARTFlowControlSet(UART0_BASE, UART_FLOWCONTROL_NONE); UARTIntDisable(UART0_BASE, UART_INT_RT); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_TX); // Enable the UART interrupt.*/ Board::setLedOn(Board::LED_GREEN, false); Board::setLedOn(Board::LED_RED, false); Board::setLedOn(Board::LED_BLUE, false); ADCInit(); }
/*-------------------------------------------------*/ void ParameterInit() { printf("\n ParameterInit\n"); masses = new double[4]; ReadConfiguration(); PulseLimitsInit(); ADCInit(); QDCInit(); PrintParameters(); printf("Finished initialising parameters - to the sorting!\n"); }
// 主函数(程序入口) int main(void) { jtagWait(); // 防止JTAG失效,重要! clockInit(); // 时钟初始化:晶振,6MHz UARTInit(); ADCInit(); KalMan(); for (;;) { } }
int main(void) { /* Start led connected to P1.29 and P1.18 */ LPC_GPIO1->FIODIR |= 0x20040000; LPC_GPIO1->FIOSET |= (1 << 29); LPC_GPIO1->FIOCLR |= (1 << 18); SystemInit(); // lpc1768_startup.c SystemCoreClockUpdate(); GPIOInit(); TimerInit(); ValueInit(); ADCInit(); comm_init(); // welcomeMsg(); set_echo(); easyWEB_init(); printchar("at+ndhcp=1\r"); printchar("at+wa=greenet\r"); printchar("at+nstcp=20\r"); printchar(" \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); while(1) { easyWEB_s_loop(); //handle_command(); //UART command if(UpdateChannel >= 3) { UpdateChannel = -1; ADCRead(0); if (mode ==1) //decide which ADC channel to read when the converter is working in different direction { Vout = ADCValues(0); Vin = ADCValues(1); } else { Vout = ADCValues(1); Vin = ADCValues(0); } Iref = ADCValues(2); Il = abs (ADCValues(3) - Iref); //get the correct inductor current MeanValues(); BangBang(); LPC_GPIO1->FIOPIN ^= (1 << 29); LPC_GPIO1->FIOPIN ^= (1 << 18); } } return 0; }
void main(void) { WatchDogStop(); PowerLevel_3(); Clk_MCLK_24M_SMCLK_3M_ACLK_32768Hz(); pDST = DMA_DST; ADCInit(); DMAInit(); __bis_SR_register(GIE); while(1); }
int myadc_getrandomseed(void){ int i,tmp,seed; ADCInit(1000000); for(i=0;i<8;i++){ tmp=ADCRead(i); tmp&=0x7; //three bits seed|=(tmp<<(i*3)); } //ADCDeinit(); seed=seed; return seed; }
void pixyInit(uint32_t slaveRomStart, const unsigned char slaveImage[], uint32_t imageSize) { platformInit(); // button, SPI_SSEL LPC_GPIO_PORT->MASK[5] = 0; LPC_GPIO_PORT->PIN[5] = 0x20; // negate SPI_SS LPC_GPIO_PORT->DIR[5] = 0x20; // SPI_SS - output // deal with P4_1, GPIO2[1] LPC_GPIO_PORT->MASK[2] = 0; LPC_GPIO_PORT->DIR[2] = 0; // set timer so we count clock cycles LPC_TIMER1->IR = 0; LPC_TIMER1->TCR = 1; LPC_TIMER1->PR = 0; // microsecond timer LPC_TIMER2->IR = 0; LPC_TIMER2->TCR = 1; LPC_TIMER2->PR = CLKFREQ_US-1; debug_frmwrk_init_clk(CLKFREQ); USB_UserInit(); lpc_printf("M4 start\n"); IPC_haltSlave(); ADCInit(); SCTInit(); CameraInit(); // start slave IPC_downloadSlaveImage(slaveRomStart, slaveImage, imageSize); IPC_startSlave(); // initialize chirp objects g_chirpUsb = new ChirpUsb(); g_chirpM0 = new ChirpM0(); // initialize devices/modules pwr_init(); spi_init(); cam_init(); rcs_init(); led_init(); //cc_init(); }
int main(void) { int timer = 0; int x; int y; char str1[16]; char str2[16]; clear_bit(DDRD,5); clear_bit(DDRD,4); set_bit(DDRB,7); set_bit(PORTD,5); set_bit(PORTD,4); set_bit(PORTB,7); LCDInit(); ADCInit(); sei(); LCDClear(); while(1) { timer ++; if (timer >= 1000) { timer = 0; if(!check_bit(PIND,5)) { } if(!check_bit(PIND,4)) { } } } }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ static void SetupHardware(void) { SystemInit(); Board_Init(); MyUSB_Init(); UARTInit(115200); #ifdef _MY_UNIT_TEST_ main_blinky(); #else Timer_Init(); #endif // #ifdef _MY_UNIT_TEST_ I2CInit(); ADCInit(); }
void pixyInit(void) #endif { // write stack guard word // STACK_GUARD = STACK_GUARD_WORD; commonInit(); #ifdef KEIL IPC_haltSlave(); #endif // clear RC servo registers to prevent and glitches upon initialization rcs_enable(0, 0); rcs_enable(1, 0); ADCInit(); SCTInit(); CameraInit(); // initialize shared memory interface before running M0 SMLink *smLink = new SMLink; // start slave #ifdef KEIL if (slaveRomStart && slaveImage && imageSize) { IPC_downloadSlaveImage(slaveRomStart, slaveImage, imageSize); IPC_startSlave(); } #else cr_start_m0(SLAVE_M0APP,&__core_m0app_START__); #endif // initialize chirp objects USBLink *usbLink = new USBLink; g_chirpUsb = new Chirp(false, false, usbLink); g_chirpUsb->setSendTimeout(3000); // set a high timeout because the host can sometimes go AWOL for a second or two.... g_chirpUsb->setRecvTimeout(3000); // set a high timeout because the host can sometimes go AWOL for a second or two.... g_chirpM0 = new Chirp(false, true, smLink); // initialize devices/modules led_init(); prm_init(g_chirpUsb); pwr_init(); cam_init(); }
void main(void) { ADCInit();//Start Analog to digital converter MotorInit();//Start the motor controller TimerPWMInit();//Start the generation of PWM signal using timers LCDInit(LS_NONE); //Initialize the LCD Module parallelInit();//Initialize the reception from the Arduino over the parallel port SetMotorLeft(0);//Start motor left at speed 0 SetMotorRight(0);//Start motor right at speed 0 /* Endless loop*/ while(1) { ADCInitiateConversion();//One analog read. Go();//Take decissions to avoid obstacles. And send orders to obstacles. } }
void MasterInitialize()//called on startup, will call the port setup etc. as well as find the appropriate setting for the pot { cli();//disable interrupts ADCInit(); PortInit();//these init values (clock and port) are taken directly from our old code ClockInit(); SerialInit(); sei();//enable interrupts return; }
void SoftReset() { BYTE ipl_backup = SRbits.IPL; SRbits.IPL = 7; // disable interrupts log_printf("SoftReset()"); TimersInit(); PinsInit(); PWMInit(); ADCInit(); UARTInit(); SPIInit(); I2CInit(); InCapInit(); // TODO: reset all peripherals! SRbits.IPL = ipl_backup; // enable interrupts }
void main(void) { SysInit(); AD9954Init(); IrInit(); ADCInit(); UIInit(); UIRefresh(); //InitManchester(); //Set the timer A1 TA1CCTL0 = CCIE; // CCR0 interrupt enabled TA1CCR0 = 3277; TA1CTL = TASSEL_1 + MC_1 + TACLR; // SMCLK, up mode, clear TAR //AD9954_OSK_H; // OSK UP SingleTone(); // 1MHz for default g_ulFrequence = 5000000; // 必须和SetFreqToHz绑定使用 SetFreqToHz(g_ulFrequence); // n Hz _EINT(); while(1){ //ADSend(0xff); _nop();_nop();_nop();_nop();_nop(); delay_ms(100); if(g_ucGetNumFlag){ //g_ulFrequence = g_ulGetNum; //SetFreqToHz(g_ulFrequence); g_dC = GetCValueByVRate(g_ulGetNum / 1000.0); UIRefresh(); //AD9954SetReg8(ASF, 1000*g_ulGetNum); //g_ulGetNum = 16415; g_ucGetNumFlag = 0; // Clear g_ulGetNum = 0; // Reset //g_dQ = GetCValueByVRate(g_fVRate); } // 进入低功耗模式 __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, Enable interrupts __no_operation(); // For debugger } }