/*
 * main.c
 */
void main() {
	init_pins();
	init_button();
	init_adc();
	init_wdt();
	WDT_delay = CURRENT_DELAY;

 	BCSCTL1 = CALBC1_8MHZ;
	DCOCTL =  CALDCO_8MHZ;

	LCD_setup();
	_bis_SR_register(GIE);	// enable interrupts
	// initialize LCD and say hello a few times :-)
	LCD_init();

	LCD_send_string((char*)msg);

	while(1){
		LCD_put(0x80+40); // cursor to line 2, first position
		snprintf(hex, 20, HEX, (int)colourArray[1], (int)colourArray[2], (int)colourArray[0]);
		LCD_send_string(hex);
	}

	_bis_SR_register(LPM0_bits);

	//delay(0); // maximum delay



}
Exemple #2
0
void main(void)
{
    init_pins();
    init_oscillator();
    SPI1_Initialize();
    
    float temp = 0;
    // Set all pins RD1-7 to inputs, RD0 (MSB is set to output)
    //TRISD = 0b11111110;
    // RC2 is PWM pin
    TRISCbits.RC2 = 0;
    
    configure_adc();
    configure_pwm();
    int ticks = 0;
    
    while (1)
    {  
        MAX_7221_INIT();
        temp = get_temperature(0);
        set_fan_speed(temp);
        if(ticks % 125 == 0) {
            MAX_7221_WRITE_FLOAT(temp, 3);
            ticks = 0;
        }
        ticks++;
    }
}
Exemple #3
0
Uart0::Error Uart0::open() {
  if (is_open())
    return kPortAlreadyOpen;

  /* Initializes the Buffers */
  in_buffer_.create("Uart0 Rx Buffer", kBufferSize);
  out_buffer_.create("Uart0 Tx Buffer", kBufferSize);

  /* Enable the UART0 peripheral. */
  MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);

  /* Configure Pins. */
  Error pins_ok = init_pins();
  if (pins_ok != kOK)
    return pins_ok;

  /* Configure UART. */
  Error uart_ok = config_uart();
  if (uart_ok != kOK)
    return uart_ok;

  /* Change the status */
  open_ = true;

  g_uart0_object = this;
  return kOK;
}
Exemple #4
0
int main(int argc, char** argv) {

//    BMXPUPBA = BMXPFMSZ - 0x4000;

//  sizeof(presets) = 17820 bits
//  0x5000 = 20480

    INTCONbits.MVEC = TRUE;           //Multi-vector interrupt mode
    asm volatile("ei");               //Autorise les macro-ASM (interruptions)

//    memcpy(&presets, flash_adress, sizeof(presets));

    init_Menus();
    init_pins();
    init_lcd();
    init_preset();
    create_tab_env();
    create_tab_frequenz();
    create_tab_period();
    init_MIDI();
//    init_pwm();
    init_dac();
    update_menu();

    while (42)
    {
        boutons();
        processEncodeur();
        WDTCONbits.WDTCLR = 1;
    }
    return (0);
}
Exemple #5
0
int main(int argc, char** argv) {

    init_pins();
    init_lcd();
    lcd_print("SynthyTwo");
    lcd_goto(1, 2);
    lcd_print("Coming Soon...");
    while (42)
        ;
    return (EXIT_SUCCESS);
}
Exemple #6
0
static void __init init_ioports(void)
{
	struct device_node *dnode;
	struct property *prop;
	int	len;

	init_pins(ARRAY_SIZE(tqm8xx_pins), &tqm8xx_pins[0]);

	cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);

	dnode = of_find_node_by_name(NULL, "aliases");
	if (dnode == NULL)
		return;
	prop = of_find_property(dnode, "ethernet1", &len);
	if (prop == NULL)
		return;

	/* init FEC pins */
	init_pins(ARRAY_SIZE(tqm8xx_fec_pins), &tqm8xx_fec_pins[0]);
}
Exemple #7
0
int main(int argc, char** argv) {

    init_pins();
    init_preset();
    init_lcd();
    lcd_print("EA  EB  EC  ED  ");
    lcd_print("SynthyTwo");
    lcd_goto(1, 2);
//    lcd_print("Coming Soon...");
    while (42)
        processEncodeur();
    return (0);
}
Exemple #8
0
int main(void) {


  init_pins();	//Initializes the leds and the read write enabler pins as outputs

  init_USART1(BOTTOM_MOTOR_BAUD); 	// initialize USART1 baud rate
  init_USART2(TOP_BOTTOM_BAUD);	// initialize USART2 baud rate

  GPIO_SetBits(GPIOD, READ_WRITE_ENABLER);	//Turns the read/write pin for rs485 to write mode
  Delay(0xFFF); //Delays to give the read/write pin time to initialize
  
  while (1){  

		//Reads the top packet, converts the top packet to motor packets, and then sends the motor packets to the motor controllers

		if(handleTopPacket())  //If the read top packet function was successful, go within the if statement
		{			
			
			GPIO_ResetBits(GPIOD, BLUE_LED);
			
			//Increments how many times the motor packets have been sent
			pollCounter++;
				
			//Waits for twenty packets to be sent to the motors before polling a motor.
			if(pollCounter > PACKETS_SENT_BEFORE_POLLED)
			{
						GPIO_SetBits(GPIOD, RED_LED);
				
				//Sends a packet to poll the motor at pollAddress
				pollMotor(pollAddress);	
				
				if(!readSlavePacket())  //If we cannot read the packet
				{
					//TODO
				}
				//Add the fault data information to the packet we are sending back to the battle station						
				
				//Increments through the addresses and goes back to address one after eight time
				pollAddress++;  //Changes which motor will be polled next
				if(pollAddress == 9)
					pollAddress = 1;
				pollCounter = 0;  //Resets the poll counter
			}
		}	
	  
		GPIO_ResetBits(GPIOD, GREED_LED);	//Turns off the led 
		GPIO_ResetBits(GPIOD, RED_LED);		
    }

  }
int main(void)
{
	// disable global interrupts
	cli();
	
	init_pins();
	init_timer1();
	
	// reenable global interrupts
	sei();
	
	// loop forever while interrupts do the real work
	// TODO: sleep cpu here instead of looping
	while(1);
}
Exemple #10
0
int main ()
{
	// Disable the ADC
	disable_adc();

	// Watchdog timer reset safety check
	wdt_reset_safety();
	
	// Initialise watchdog timer
	init_wdt();

	// Identify input and output pins
	init_pins();

	// Buffer for text
	char s[20];

	// Setup direction and port for debug logging
	STX_PORT |= 1<<STX_BIT;
	STX_DDR |= 1<<STX_BIT;

	// Initialise DSP
	int i = 0;
	for (; i < MAX_READINGS; i++) readings[i] = 0;

	for (;;)
	{
		// Go to sleep
		sleep_avr();
		
		// Read VCC and convert to base 10 number
		long vcc = read_vcc();

		dsp(vcc);
		utoa(average, s, 10);

		// Output VCC to soft serial PIN STX_BIT
		sputs(s);
		sputs("\n\r");

		if (average > FULL_CHARGE_MV)
		{
			init_wdt_05s();
			blink();
		}
		else init_wdt();	
	}
}
Exemple #11
0
int main(int argc, char** argv) {

    //---------- FLASH ------------
    // MCHP_FLASH_ENABLE            non fonctionnel
    // MCHPCONbits.FAEN = 1;        non fonctionnel
    // while(MCHPCONbits.FCBUSY);   non fonctionnel

    // NVMCONbits.WR = 1;
    // NVMCONbits.NVMOP = ?;

    init_pins();
    init_preset();
    init_Menus();
    INTCONbits.MVEC = TRUE;           //Multi-vector interrupt mode
    asm volatile("ei");               //Autorise les macro-ASM (interruptions)
    init_lcd();
    create_tab_env();
    create_tab_frequenz();
    create_tab_period();
    init_MIDI();
    init_pwm();

    init_dac();
/*    PMCON = 0;
    PMAEN = 0;
    PMMODE = 0;
    PMADDR = 0;
    PMSTAT = 0;
    PMDIN = 0;
    PMDOUT = 0;
    AD1CON1 = 0;
    AD1CON2 = 0;
    AD1CON3 = 0;
    AD1CHS = 0;
    AD1CSSL = 0;
    U2STA = 0;
    U2MODE = 0;*/
    update_menu();

    while (42) {
        boutons();
        processEncodeur();
    }
    return (0);
}
Exemple #12
0
int init(){
  uint32_t revision = getBoardRev();
  uint32_t offset = ((revision == 0xa01041 || revision == 0xa21041)?0x1F000000:0);
  if(revision == 0xa01041)
    revision = 0x10;//pi2 has B+ pinout
  else if(revision == 0xa21041)
    revision = 0x13;//pi2 has B+ pinout
  if(revision >= PINMASKS_LEN || !rpi_model_pinmasks[revision]){
    fprintf(stderr, "UNKNOWN_REVISION: 0x%08X\n", revision);
    return 1;
  }
  if(map_registers(offset))
    return 1;
  
  _board_revision = revision;
  init_pins();
  srand(time(NULL));
  return 0;
}
Exemple #13
0
void uart_init(void)
{
	init_pins();

    /*
     * Setting a baud rate found on p.488 of user guide.
     * Initializing the UART is on p.479 of user guide.
     */


	UCA0CTL1 |= UCSWRST;

	/*
	 * The following code block sets the clock source as the ACLK which should be running
	 * at 32.678 kHz.
	 *
	 * UCOS16 = 0; UCA0BR0 = 3; UCA0BRF0 = unchanged; UCA0BRS0 = 0x92
	 *
	 * TODO : THIS DOESN'T WORK. PERHAPS THE CRYSTAL IS NOT WORKING PROPERLY OR YOU
	 * ARE MISUNDERSTANDING HOW TO SOURCE FROM THE CRYSTAL.
	 */


//	UCA0CTL1 |= UCSSEL_1;	//set the baud rate clock source to be ACLK
//	UCA0BR0 = 3;			//clock prescaler
//	UCA0BR1 = 0;
//	UCA0MCTLW |= 0x9200;	//set the whole register in one instruction

	/*
	 * The following code block sets the clock source as the SMCLK which should be running
	 * at 1 MHz
	 *
	 * UCOS16 = 1; UCA0BR0 = 6; UCA0BRF0 = 8; UCA0BRS0 = 0x20; <-- should probably be 0x11
	 */

	UCA0CTL1 |= UCSSEL_2;	//set the baud rate clock source to be SMCLK
	UCA0BR0 = 6;			//clock prescaler
	UCA0BR1 = 0;
	UCA0MCTLW |= UCOS16;
	UCA0MCTLW |= 0x1180;

	UCA0CTL1 &= ~UCSWRST;
}
void bbio::open(){
    
    // GPIO init
    init();
    init_pins(); // ALL 5 pins are HIGH except for GND
    init_DAConvAD5328();

    //BBBIO init
    iolib_init();
    BBBIO_sys_Enable_GPIO(BBBIO_GPIO1);
    BBBIO_GPIO_set_dir(BBBIO_GPIO1 ,
                       port_dout_SPI[0] ,
                       port_din_SPI[0] | port_clk_SPI[0] | port_cs_SPI[0]);
    
    BBBIO_GPIO_low(BBBIO_GPIO1 ,port_din_SPI[0]);
    BBBIO_GPIO_low(BBBIO_GPIO1 ,port_clk_SPI[0]);
    BBBIO_GPIO_low(BBBIO_GPIO1 ,port_cs_SPI[0]);
    
}
int read_my_testcase(char *cells_file,char *nets_file, char *area_file, double *chip_width, double *chip_height)
{
    FILE *cells, *area, *nets;
	char buffer[MAX_LINE_CHARS] = {0,};
	double utilization = 0;

	cells = fopen(cells_file, "r");	
	
	if (cells == NULL) {
		printf("Could not open cells file.");
		return 1;
	}
	
	while (fgets(buffer, MAX_LINE_CHARS, cells) != NULL) {
		create_lists_depending_on_type(buffer);
	}
	fclose(cells);

	area = fopen(area_file, "r");
	if(area != NULL) {
		fscanf(area,"chip height = %lf chip width = %lf", chip_height, chip_width);
		fclose(area);		
	}
	else {
		printf("No area file given. Calculating area form circuit.\n");
		scanf("%lf", &utilization);		
		calculate_area(chip_width, chip_height, utilization);
		init_pins(*chip_width, *chip_height);
	}
	
	nets = fopen(nets_file, "r");
	if(nets == NULL) {
		printf("Could not open nets file.\n");
		return 1;
	}
	while (fgets(buffer, MAX_LINE_CHARS, nets) != NULL) {
		create_net_list(buffer);
	}
	fclose(nets);
	
	return 0;
}
Exemple #16
0
/**
 * @return Return 0 on success and not 1 on failure.
 */
int init(){
  RASPBERRY_PI_INFO_T info;
  getRaspberryPiInformation(&info);

  uint32_t offset = info.peripheralBase - 0x20000000;

  if (info.model == RPI_MODEL_B_PI_2 || info.model == RPI_MODEL_ZERO) {
    info.revisionNumber = 0x10;
  }
  if(info.revisionNumber >= PINMASKS_LEN || !rpi_model_pinmasks[info.revisionNumber]){
    fprintf(stderr, "UNKNOWN_REVISION: 0x%08X\n", info.revisionNumber);
    return 1;
  }
  if(map_registers(offset))
    return 1;
  
  _board_revision = info.revisionNumber;
  init_pins();
  srand(time(NULL));
  return 0;
}
Exemple #17
0
int main (void)
{		
	init_pins();
	char* bt_data = bt_init();
	
	
	
	
    pacer_init (LOOP_POLL_RATE);
	pio_output_set(PIO_AUX_ENABLE, 0);
	
	short aux_power = 0;
    while (1)
    {		
		pacer_wait ();
		
		pio_output_set(PIO_LED_G, bt_connected());
		
		if (bt_read()) {
			process_command(bt_data);
		}
	}		
}
Exemple #18
0
void matrix_init(void) {
  debug_enable = true;
  debug_matrix = true;
  debug_mouse  = true;

  // Set pinout for right half if pinout for that half is defined
  if (!isLeftHand) {
#ifdef MATRIX_ROW_PINS_RIGHT
    const uint8_t row_pins_right[MATRIX_ROWS] = MATRIX_ROW_PINS_RIGHT;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
      row_pins[i] = row_pins_right[i];
    }
#endif
#ifdef MATRIX_COL_PINS_RIGHT
    const uint8_t col_pins_right[MATRIX_COLS] = MATRIX_COL_PINS_RIGHT;
    for (uint8_t i = 0; i < MATRIX_COLS; i++) {
      col_pins[i] = col_pins_right[i];
    }
#endif
  }

  thisHand = isLeftHand ? 0 : (ROWS_PER_HAND);
  thatHand = ROWS_PER_HAND - thisHand;

  // initialize key pins
  init_pins();

  // initialize matrix state: all keys off
  for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
    matrix[i] = 0;
  }

  debounce_init(ROWS_PER_HAND);

  matrix_init_quantum();
}
Exemple #19
0
int main(void) {
    debug_init();
    init_fcy();
    init_pins();

    // Start level - inverted
    LATBbits.LATB15 = 1;

// Each bit is encoded as:
//  0: High(0.4 us +- 150 ns) then Low(0.85 us +- 150ns)
//  1: High(0.8 us +- 150 ns) then Low(0.45 us +- 150ns)
//
// The timing is very sensitive and jmps and shifts takes a long time.
// I had to rearrange the if statement and put the shifts in the "long"
// part of the bits. The Nop() lengths were timed with the help of an
// oscilloscop.

#define HIGH_LONG()  Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop()
#define HIGH_SHORT() Nop(); Nop(); Nop()
#define LOW_LONG()   Nop(); Nop(); Nop(); Nop(); Nop(); Nop()
#define LOW_SHORT()

#define INVERT_BOOL(x) ((x) = (x) == 0)

#define SEND_AND_SHIFT_BIT(value) \
    INVERT_BOOL(LATBbits.LATB15); \
    if (!(value & 0b10000000)) { \
        HIGH_SHORT(); \
        INVERT_BOOL(LATBbits.LATB15); \
        value <<= 1; \
        LOW_LONG(); \
    } else { \
        value <<= 1; \
        HIGH_LONG(); \
        INVERT_BOOL(LATBbits.LATB15); \
        LOW_SHORT(); \
    }
    

    
    // Get it to shine!

    // RGB values for the nine LEDs
    // plus three extra values to make shifting of the colors easier.
    char ga[9 + 3];
    char ra[9 + 3];
    char ba[9 + 3];

    // Intensity progression. Offset sine curve.
    // Use int instead of floats.
    // 1000 * (1 + sin(360 / 9 * i) when i = [0..8]
    unsigned int intensity_progression[9] = {
        1000,
        1642,
        1984,
        1866,
        1342,
        658,
        134,
        16,
        356
    };


#define INTENSITY_MAX 2000
#define AMPLITUDE 30

    // Add the intensity curve and let the intensity be shifted between the colors.
    int j;
    for (j = 0; j < 9; j++) {
        unsigned char intensity = (unsigned char) (intensity_progression[j] * AMPLITUDE) / INTENSITY_MAX;
        ga[(j + 0) % 9] = intensity;
        ra[(j + 3) % 9] = intensity;
        ba[(j + 6) % 9] = intensity;
    }

    while (1) {
        int i;

        // This part is not really timing sensitive,
        // since we want to wait a while between every color shift.

        // Shift one LED color at a time.
#define SHIFT 1

        // Shift the LED colors
        for (i = 8; i >= 0; i--) {
            ga[i + SHIFT] = ga[i];
            ra[i + SHIFT] = ra[i];
            ba[i + SHIFT] = ba[i];
        }
        // Take care of the colors that were shifted out of the 0..8 first position
        // and move them to the begining of the arrays.
        for (i = 0; i < SHIFT; i++) {
            ga[i] = ga[9 + i];
            ra[i] = ra[9 + i];
            ba[i] = ba[9 + i];
        }

        // Delay before updating the LED colors.
        delay_ms(100);

        // Send the colors to all nine LEDs.
        for (j = 0; j < 9; j++) {
            char g = ga[j];
            char r = ra[j];
            char b = ba[j];

            // Send and shift the MSB bit for green.
            SEND_AND_SHIFT_BIT(g);
            SEND_AND_SHIFT_BIT(g);
            SEND_AND_SHIFT_BIT(g);
            SEND_AND_SHIFT_BIT(g);
            SEND_AND_SHIFT_BIT(g);
            SEND_AND_SHIFT_BIT(g);
            SEND_AND_SHIFT_BIT(g);
            SEND_AND_SHIFT_BIT(g);

            // Send and shift the MSB bit for red.
            SEND_AND_SHIFT_BIT(r);
            SEND_AND_SHIFT_BIT(r);
            SEND_AND_SHIFT_BIT(r);
            SEND_AND_SHIFT_BIT(r);
            SEND_AND_SHIFT_BIT(r);
            SEND_AND_SHIFT_BIT(r);
            SEND_AND_SHIFT_BIT(r);
            SEND_AND_SHIFT_BIT(r);

            // Send and shift the MSB bit for blue.
            SEND_AND_SHIFT_BIT(b);
            SEND_AND_SHIFT_BIT(b);
            SEND_AND_SHIFT_BIT(b);
            SEND_AND_SHIFT_BIT(b);
            SEND_AND_SHIFT_BIT(b);
            SEND_AND_SHIFT_BIT(b);
            SEND_AND_SHIFT_BIT(b);
            SEND_AND_SHIFT_BIT(b);
        }
        // Must wait at least 50 us before trying to send new color bits.
        delay_ms(1);
    }

    while (1);

    return 0;
}
Exemple #20
0
int main(int argc, char *argv[])
{
	// Handle SIGPIPE
	struct sigaction pipeAct;
	memset(&pipeAct, 0, sizeof(struct sigaction));
	pipeAct.sa_handler = pipeHandler;
	if (sigaction(SIGPIPE, &pipeAct, NULL) < 0) {
		f**k(FUCK_HARDCORE, "sigaction error: %s\n", fuckerror());
	}

	init_socket();
	init_pins();

    while (1) {
		if (acceptClient() < 0) continue; // Error on accept

		// Read resolution
		read(clientSock_fd, &xres, sizeof(uint32_t));
		read(clientSock_fd, &yres, sizeof(uint32_t));

		// Create input events
		struct input_eventx ev_x;		// Relative on the x axis
		ev_x.type = EV_REL;
		ev_x.code = REL_X;
		struct input_eventx ev_y;		// Relative on the y axis
		ev_y.type = EV_REL;
		ev_y.code = REL_Y;
		struct input_eventx ev_l;		// Left mouse button
		ev_l.type = EV_KEY;
		ev_l.code = BTN_LEFT;
		struct input_eventx ev_r;		// Right mouse button
		ev_r.type = EV_KEY;
		ev_r.code = BTN_RIGHT;
		struct input_eventx ev_syn;		// Sync event
		ev_syn.type = EV_SYN;
		ev_syn.code = SYN_REPORT;
		ev_syn.value = 0;

		// Set mouse to (0,0)
		ev_x.value = -xres;
		ev_y.value = -yres;
		if (sendEvent(&ev_x) < 0 || sendEvent(&ev_y) < 0 || sendEvent(&ev_syn) < 0) continue;

		int lmb_state = 0, rmb_state = 0;
		int x_old = 0, y_old = 0, x = 0, y = 0, px = 0, py = 0, a, b;
		int sync, tolerance = 3; // Avoids unwanted mouse jitter

		while (1) {
			sync = 0;
			// Handle button clicks
			if (digitalRead(GPIO_LMB) == HIGH && lmb_state == 0) {
				ev_l.value = lmb_state = 1;
				if (sendEvent(&ev_l) < 0) break;
				sync = 1;
			}
			if (digitalRead(GPIO_LMB) == LOW && lmb_state == 1) {
				ev_l.value = lmb_state = 0;
				if (sendEvent(&ev_l) < 0) break;
				sync = 1;
			}
			if (digitalRead(GPIO_RMB) == HIGH && rmb_state == 0) {
				ev_r.value = rmb_state = 1;
				if (sendEvent(&ev_r) < 0) break;
				sync = 1;
			}
			if (digitalRead(GPIO_RMB) == LOW && rmb_state == 1) {
				ev_r.value = rmb_state = 0;
				if (sendEvent(&ev_r) < 0) break;
				sync = 1;
			}

			// Handle mouse move
		 	a = analogRead(MCP3008_PIN_BASE);
		 	b = analogRead(MCP3008_PIN_BASE + 1);
			if ((a - px) > tolerance || (px - a) > tolerance || a == 0 || a == ANALOG_MAX) {
				px = a;
				x = (int)(px * (xres - 1) / (double)ANALOG_MAX);
				ev_x.value = x - x_old;
				x_old = x;
				if (sendEvent(&ev_x) < 0) break;
				sync = 1;
			}
			if ((b - py) > tolerance || (py - b) > tolerance || b == 0 || b == ANALOG_MAX) {
				py = b;
				y = (int)(py * (yres - 1) / (double)ANALOG_MAX);
				ev_y.value = y - y_old;
				y_old = y;
				if (sendEvent(&ev_y) < 0) break;
				sync = 1;
			}

			// If anything sent, sync
			if (sync && sendEvent(&ev_syn) < 0) break;

			usleep(20000);
		}

		// If any of the code from the while above breaks, move to the next client
		continue;
	}

	// Clean shit
	close(clientSock_fd);
 	close(sock_fd);

 	return 0;
}
Exemple #21
0
int main(void)
{
	unsigned long ulPeriod;
	unsigned long ulDelay;

	unsigned long recvData = 11;

	volatile int status = 0;

	char buffer[40];
	unsigned int bytesdRead;

	FRESULT res;
	FIL fileobj;

	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

	//Initialize pins
	init_pins();

	//Initialize peripherals
	init_periph();

	I2CMasterInitExpClk(I2C0_MASTER_BASE, SysCtlClockGet(), false);//false for 100kHz mode
	    //0x68 is the 7-bit address of the DS1307
	I2CMasterSlaveAddrSet(I2C0_MASTER_BASE, 0x68, false);//true for a read action
	I2CMasterDataPut(I2C0_MASTER_BASE, 0x10);      //first Date/Time Register
	I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND);
	while(I2CMasterBusy(I2C0_MASTER_BASE)){}
	I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
	while(I2CMasterBusy(I2C0_MASTER_BASE)){}
	recvData = I2CMasterDataGet(I2C0_MASTER_BASE);
	while(I2CMasterBusy(I2C0_MASTER_BASE)){}

	fs_mount();

	if(disk_status(0) == 0)
	{
		status++;
	}
	else
	{
	    status--;
	}

	if (status == 1) {
		res = f_open(&fileobj, "config.txt", FA_OPEN_EXISTING | FA_READ);
		res = f_read(&fileobj, buffer, 6, &bytesdRead);
	}

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0);

	ulPeriod = SysCtlClockGet() / 10;
	ulDelay = ((ulPeriod / 2) / 3) - 4 ;

	while(1)
	{
		// Turn on the LED
		GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0, 0x01);

		// Delay for a bit
		SysCtlDelay(ulDelay);

		// Turn off the LED
		GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0, 0x00);

		// Delay for a bit
		SysCtlDelay(ulDelay);
	}
}
Exemple #22
0
// main init function executed 1 time only at boot
void setup(){
	init_pins();
	init_sd();
	load_os_msgs_from_sd();
	load_drugs_from_sd();	
}
Exemple #23
0
void custom_matrix_init(void) {
  pca9555_init(IC1);
  pca9555_init(IC2);

  init_pins();
}
Exemple #24
0
void uninit(){
  init_pins();
  unmap_registers();
}