void wifi_on() { write_pin(CC3000_SW_EN_PIN, false); delay(10000000); write_pin(WIFI_POWER_EN_PIN, true); ssp_init(CC3000_SPI_HW, SSP_FRAMEFORMAT_SPI, 0, true, 8, 20); write_pin(CC3000_SW_EN_PIN, true); cc3000_init(CC3000_IRQ_PIN); }
void systick() { static uint32_t counter; if (read_pin(BUTTON_PIN)) counter++; else counter--; write_pin(LED1_PIN, (counter / 50) & 1); write_pin(LED2_PIN, ((counter + 10) / 50) & 1); write_pin(LED3_PIN, ((counter + 20) / 50) & 1); }
void audio_on() { audio_off(); //Turn off to make sure we do a proper reset delay(1000000); i2s_init(SPARROW_I2S); write_pin(AUDIO_POWER_EN_PIN, true); delay(1000000); //TLV320AIC3100 spec: Reset low for at least 10ns write_pin(AUDIO_NRESET, true); delay(1000000); //TLV320AIC3100 spec: 1ms min after reset }
int main(int argc, char **argv){ IOPi_init(0x20); // initialise one of the io pi buses on i2c address 0x20 set_port_direction(0x20,0, 0x00); // set the direction for bank 0 to be outputs set_port_direction(0x20,1, 0x00); // set the direction for bank 1 to be outputs write_port(0x20,1, 0xFF); while (1){ write_pin(0x20,1, 1); // turn pin 1 on and off at 1 second intervals usleep(1000000); write_pin(0x20,1, 0); usleep(1000000); } return (0); }
void ledstripe_on(uint16_t num_leds, uint8_t* in_ledstripe_buffer) { ledstripe_buffer = in_ledstripe_buffer; ledstripe_buffer_len = LEDSTRIPE_BUFFER_CAPACITY(num_leds); ledstripe_idx = ledstripe_buffer_len; usart_configure_pin(USART0_TXD_GROUP, USART0_TXD_IDX, USART0_TXD_MODE, false, true); usart_configure_pin(USART0_RXD_GROUP, USART0_RXD_IDX, USART0_RXD_MODE, true, true); usart_configure_pin(USART0_UCLK_GROUP, USART0_UCLK_IDX, USART0_UCLK_MODE, false, true); write_pin(PORT_5V_EN_PIN, true); usart_init_sync_master(LEDSTRIPE_USART_IDX, 8, 3200000, 16, USART_FCR_RXTRIGLVL_8, NULL, NULL/*ledstripe_refill*/, NULL); }
/***************************************************************************** * Subroutine: lcd_init * * Description: * This subroutine initializes the LCD device. * * Input Parameters: * LCD struct reference * * Output Parameters: * None * * Subroutines: * lcd_clear * lcd_tx_byte * __delay_ms * __delay_us *****************************************************************************/ void lcd_init(LCD_t* lcd) { write_pin(lcd->rw_pin, 0); write_pin(lcd->rs_pin, 0); /*** Power-On Initialization ***/ /* Wait 15 ms */ __delay_ms(15); /* Write 0x3, pulse enable, wait 4.1 ms or longer */ *lcd->data_bus = 0x3 << lcd->bus_offset; strobe_pin(lcd->en_pin); __delay_ms(5); /* Write 0x3, pulse enable, wait 100 us or longer */ *lcd->data_bus = 0x3 << lcd->bus_offset; strobe_pin(lcd->en_pin); __delay_us(100); /* Write 0x3, pulse enable, wait 40 us or longer */ *lcd->data_bus = 0x3 << lcd->bus_offset; strobe_pin(lcd->en_pin); __delay_us(40); /* Write 0x2, pulse enable, wait 40 us or longer */ *lcd->data_bus = 0x2 << lcd->bus_offset; /* Set 4-bit mode */ strobe_pin(lcd->en_pin); __delay_us(40); /*** Display Configuration ***/ lcd_tx_byte(lcd, 0x28); /* 4-bit operation */ __delay_us(40); lcd_tx_byte(lcd, 0x06); /* Automatically increase address pointer */ __delay_us(40); lcd_tx_byte(lcd, 0x0C); /* Turn display on */ __delay_us(40); lcd_clear(lcd); }
void ethernet_on() { ethernet_off(); //turn off for a proper reset delay(10*DELAY_MS_UNITS); // set_digital_input(ETH_POWER_EN_PIN, true, false, false); // write_pin(ETH_POWER_EN_PIN, true); delay(10*DELAY_MS_UNITS); write_pin(ETH_NRST_PIN, true); delay(10*DELAY_MS_UNITS); eth_init(); lan_init(); }
void bl3_motor_turn_off(BL3MotorFD motor) { BL3Motor * mymot = bl3_motors->motors[motor]; write_pin(mymot->pin_1_H, LOW); write_pin(mymot->pin_1_L, LOW); write_pin(mymot->pin_2_H, LOW); write_pin(mymot->pin_2_L, LOW); write_pin(mymot->pin_3_H, LOW); write_pin(mymot->pin_3_L, LOW); }
int process_packet(cmd_packet *packet){ char buf[16]; switch(packet->type){ case TYPE_REG_READ: reg_input_pin(packet->data[0]); break; case TYPE_REG_WRITE: reg_output_pin(packet->data[0]); break; case TYPE_UNREG: unreg_pin(packet->data[0]); break; case TYPE_SET: write_pin(packet->data[0],packet->data[1]); break; case TYPE_RESET: break; default: return -1; } return 0; }
/***************************************************************************** * Subroutine: lcd_puts * * Description: * This subroutine writes a string to the LCD. * * Input Parameters: * LCD struct reference * Data to write to LCD * * Output Parameters: * None * * Subroutines: * lcd_write *****************************************************************************/ void lcd_puts(LCD_t* lcd, const char *data) { write_pin(lcd->rs_pin, 1); while (*data) lcd_write(lcd, *data++); }
/***************************************************************************** * Subroutine: lcd_cmd * * Description: * This private subroutine sends a command to the LCD device. * * Input Parameters: * LCD struct reference * LCD Command * * Output Parameters: * None * * * Subroutines: * lcd_tx_byte *****************************************************************************/ static void lcd_cmd(LCD_t* lcd, unsigned char cmd) { write_pin(lcd->rs_pin, 0); write_pin(lcd->rw_pin, 0); lcd_tx_byte(lcd, cmd); }
void audio_off() { write_pin(AUDIO_POWER_EN_PIN, false); write_pin(AUDIO_NRESET, false); i2s_shutdown(SPARROW_I2S); }
/***************************************************************************** * Subroutine: lcd_putch * * Description: * This subroutine writes a character to the LCD. * * Input Parameters: * LCD struct reference * Byte to write to LCD * * Output Parameters: * None * * Subroutines: * lcd_write *****************************************************************************/ void lcd_putch(LCD_t* lcd, unsigned char data) { write_pin(lcd->rs_pin, 1); lcd_write(lcd, data); }
/*! * \brief Write a SIP pin through hole footprint. * * The pin/pad numbering scheme of the SIP package is: \n * 1 \n * 2 \n * 3 \n * 4 \n * * \return \c EXIT_FAILURE when errors were encountered, * \c EXIT_SUCCESS when OK. */ int sip_write_footprint () { gdouble xmax; gdouble xmin; gdouble ymax; gdouble ymin; gdouble x_text; gdouble y_text; gint pin_number; gchar *pin_pad_name = g_strdup (""); gchar *pin_pad_flags = g_strdup (""); gint i; number_of_columns = 1; /* Attempt to open a file with write permission. */ fp = fopen (footprint_filename, "w"); if (!fp) { g_log ("", G_LOG_LEVEL_WARNING, _("could not open file for %s footprint: %s."), footprint_type, footprint_filename); fclose (fp); return (EXIT_FAILURE); } /* Print a license if requested. */ if (license_in_footprint) { write_license (); } /* Determine (extreme) courtyard dimensions based on pin/pad * properties */ xmin = multiplier * ( (((pad_diameter > pad_length) ? pad_diameter : pad_length) / -2.0) - pad_solder_mask_clearance ); xmax = multiplier * ( (((pad_diameter > pad_length) ? pad_diameter : pad_length) / 2.0) + pad_solder_mask_clearance ); ymin = multiplier * ( (((-number_of_rows + 1) / 2.0) * pitch_y) - (((pad_diameter > pad_width) ? pad_diameter : pad_width) / 2.0) - pad_solder_mask_clearance ); ymax = multiplier * ( (((number_of_rows - 1 ) / 2.0) * pitch_y) + (((pad_diameter > pad_width) ? pad_diameter : pad_width) / 2.0) + pad_solder_mask_clearance ); /* Determine (extreme) courtyard dimensions based on package * properties */ if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin) { xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)); } if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax) { xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)); } if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin) { ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)); } if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax) { ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)); } /* If the user input is using even more real-estate then use it */ if (multiplier * (-courtyard_length / 2.0) < xmin) { xmin = multiplier * (-courtyard_length / 2.0); } if (multiplier * (courtyard_length / 2.0) > xmax) { xmax = multiplier * (courtyard_length / 2.0); } if (multiplier * (-courtyard_width / 2.0) < ymin) { ymin = multiplier * (-courtyard_width / 2.0); } if (multiplier * (courtyard_width / 2.0) > ymax) { ymax = multiplier * (courtyard_width / 2.0); } /* Write element header * Guess for a place where to put the refdes text */ x_text = 0.0 ; /* already in mil/100 */ y_text = (ymin - 10000.0); /* already in mil/100 */ write_element_header (x_text, y_text); /* Write pin and/or pad entities */ for (i = 0; (i < number_of_rows); i++) { pin_number = 1 + i; write_pin ( pin_number, /* pin number */ pin_pad_name, /* pin name */ 0, /* x0 coordinate */ multiplier * ((((-number_of_rows - 1) / 2.0) +1 + i) * pitch_y), /* y0-coordinate */ multiplier * pad_diameter, /* width of the annulus ring (pad) */ multiplier * 2 * pad_clearance, /* clearance */ multiplier * (pad_diameter + (2 * pad_solder_mask_clearance)), /* solder mask clearance */ multiplier * pin_drill_diameter, /* pin drill diameter */ (pin1_square && (pin_number == 1)) ? "square" : pin_pad_flags /* flags */ ); if (!strcmp (pad_shape, "rounded pad, elongated")) { if (!strcmp (pin_pad_flags, "")) pin_pad_flags = g_strconcat (pin_pad_flags, "onsolder", NULL); else pin_pad_flags = g_strconcat (pin_pad_flags, ",onsolder", NULL); write_pad ( pin_number, /* pad number = pin_number */ pin_pad_name, /* pad name */ multiplier * (-pad_width + pad_length) / 2.0, /* x0 coordinate */ multiplier * ((((-number_of_rows - 1) / 2.0) + 1 + i) * pitch_y), /* y0-coordinate */ multiplier * (pad_width - pad_length) / 2.0, /* x1 coordinate */ multiplier * ((((-number_of_rows - 1) / 2.0) + 1 + i) * pitch_y), /* y1-coordinate */ multiplier * pad_width, /* width of the pad */ multiplier * 2 * pad_clearance, /* clearance */ multiplier * (pad_width + (2 * pad_solder_mask_clearance)), /* solder mask clearance */ pin_pad_flags /* flags */ ); } } /* Write a package body on the silkscreen */ if (silkscreen_package_outline) { fprintf (fp, "# Write a package body on the silkscreen\n"); write_rectangle ( multiplier * ((-package_body_length) / 2.0), /* xmin-coordinate */ multiplier * ((-package_body_width) / 2.0), /* ymin-coordinate */ multiplier * ((package_body_length) / 2.0), /* xmax-coordinate */ multiplier * ((package_body_width) / 2.0), /* ymax-coordiante */ multiplier * silkscreen_line_width ); } /* Write a pin #1 marker on the silkscreen */ if (silkscreen_indicate_1) { fprintf (fp, "# Write a pin 1 marker on the silkscreen\n"); /* Write a marker around pin #1 inside the package outline */ write_element_line ( multiplier * (-package_body_length / 2.0), /* x0-coordinate */ multiplier * ((((-number_of_rows - 1) / 2.0) + 1.5) * pitch_y), /* y0-coordinate */ multiplier * (package_body_length / 2.0), /* x1-coordinate */ multiplier * ((((-number_of_rows - 1) / 2.0) + 1.5) * pitch_y), /* y1-coordinate */ multiplier * (silkscreen_line_width) ); /* Write a triangle shaped marker between package outline and maximum used real estate */ if (xmax > ((multiplier * package_body_length) / 2)) { write_element_line ( multiplier * (-package_body_length / 2.0), /* x0-coordinate */ multiplier * (((-number_of_rows + 1) / 2.0) * pitch_y), /* y0-coordinate */ (multiplier * (-package_body_length / 2.0)) - 2500 , /* x1-coordinate */ (multiplier * (((-number_of_rows + 1) / 2.0) * pitch_y)) - 1250, /* y1-coordinate */ multiplier * (silkscreen_line_width) ); write_element_line ( multiplier * (-package_body_length / 2.0), /* x0-coordinate */ multiplier * (((-number_of_rows + 1) / 2.0) * pitch_y), /* y0-coordinate */ (multiplier * (-package_body_length / 2.0)) - 2500 , /* x1-coordinate */ (multiplier * (((-number_of_rows + 1) / 2.0) * pitch_y)) + 1250, /* y1-coordinate */ multiplier * (silkscreen_line_width) ); write_element_line ( (multiplier * (-package_body_length / 2.0)) - 2500 , /* x0-coordinate */ (multiplier * (((-number_of_rows + 1) / 2.0) * pitch_y)) - 1250, /* y0-coordinate */ (multiplier * (-package_body_length / 2.0)) - 2500 , /* x1-coordinate */ (multiplier * (((-number_of_rows + 1) / 2.0) * pitch_y)) + 1250, /* y1-coordinate */ multiplier * (silkscreen_line_width) ); } } /* Write a courtyard on the silkscreen */ if (courtyard) { fprintf (fp, "# Write a courtyard on the silkscreen\n"); write_rectangle ( xmin, /* already in mil/100 */ ymin, /* already in mil/100 */ xmax, /* already in mil/100 */ ymax, /* already in mil/100 */ multiplier * courtyard_line_width ); } /* Write attributes to the footprint file. */ if (attributes_in_footprint) { write_attributes (); } /* Finishing touch. */ fprintf (fp, "\n"); fprintf (fp, ")\n"); fclose (fp); /* We are ready creating a footprint. */ if (verbose) { g_log ("", G_LOG_LEVEL_INFO, _("wrote a footprint for a %s package: %s."), footprint_type, footprint_filename); } return (EXIT_SUCCESS); }
/***************************************************************************** * Subroutine: lcd_disable * * Description: * This subroutine disables the LCD. * * Input Parameters: * LCD struct reference * * Output Parameters: * None * * Subroutines: * None *****************************************************************************/ void lcd_disable(LCD_t* lcd) { write_pin(lcd->en_pin, 0); write_pin(lcd->rw_pin, 0); }
void bl3_motor_step(BL3MotorFD motor) { BL3Motor * mymot = bl3_motors->motors[motor]; bl3_motor_turn_off(motor); analog_write(mymot->pin_current, mymot->current); switch(mymot->status) { case (0): { write_pin(mymot->pin_1_H, HIGH); write_pin(mymot->pin_2_L, HIGH); mymot->status++; }break; case (1): { write_pin(mymot->pin_3_H, HIGH); write_pin(mymot->pin_2_L, HIGH); mymot->status++; }break; case (2): { write_pin(mymot->pin_3_H, HIGH); write_pin(mymot->pin_1_L, HIGH); mymot->status++; }break; case (3): { write_pin(mymot->pin_2_H, HIGH); write_pin(mymot->pin_1_L, HIGH); mymot->status++; }break; case (4): { write_pin(mymot->pin_2_H, HIGH); write_pin(mymot->pin_3_L, HIGH); mymot->status++; }break; case (5): { write_pin(mymot->pin_1_H, HIGH); write_pin(mymot->pin_3_L, HIGH); mymot->status = 0; }break; default: { // not good :-0 mymot->status = 0; } } }
void ledstripe_off() { write_pin(PORT_5V_EN_PIN, false); ledstripe_buffer = NULL; ledstripe_buffer_len = 0; }
/*! * \brief Write a footprint for a PGA package. * * \return \c EXIT_FAILURE when errors were encountered, * \c EXIT_SUCCESS when OK. */ int pga_write_footprint () { gdouble xmax; gdouble xmin; gdouble ymax; gdouble ymin; gdouble x_text; gdouble y_text; gdouble dx; gint pin_number; gchar *pin_pad_name = g_strdup (""); gchar *pin_pad_flags = g_strdup (""); gint i; gint j; /* Attempt to open a file with write permission. */ fp = fopen (footprint_filename, "w"); if (!fp) { g_log ("", G_LOG_LEVEL_WARNING, _("could not open file for %s footprint: %s."), footprint_type, footprint_filename); fclose (fp); return (EXIT_FAILURE); } /* Print a license if requested. */ if (license_in_footprint) { write_license (); } /* Determine (extreme) courtyard dimensions based on pin/pad * properties */ xmin = multiplier * ( ((-pitch_x * number_of_columns) / 2.0) - (pad_diameter / 2.0) - pad_solder_mask_clearance ); xmax = multiplier * ( ((pitch_x * number_of_columns) / 2.0) + (pad_diameter / 2.0) + pad_solder_mask_clearance ); ymin = multiplier * ( ((-pitch_y * number_of_rows) / 2.0) - (pad_diameter / 2.0) - pad_solder_mask_clearance ); ymax = multiplier * ( ((pitch_y * number_of_rows) / 2.0) + (pad_diameter / 2.0) + pad_solder_mask_clearance ); /* Determine (extreme) courtyard dimensions based on package * properties */ if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin) xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)); if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax) xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)); if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin) ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)); if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax) ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)); /* If the user input is using even more real-estate then use it */ if (multiplier * (-courtyard_length / 2.0) < xmin) xmin = multiplier * (-courtyard_length / 2.0); if (multiplier * (courtyard_length / 2.0) > xmax) xmax = multiplier * (courtyard_length / 2.0); if (multiplier * (-courtyard_width / 2.0) < ymin) ymin = multiplier * (-courtyard_width / 2.0); if (multiplier * (courtyard_width / 2.0) > ymax) ymax = multiplier * (courtyard_width / 2.0); /* Write element header * Guess for a place where to put the refdes text */ x_text = 0.0 ; /* already in mil/100 */ y_text = (ymin - 10000.0); /* already in mil/100 */ write_element_header (x_text, y_text); /* Write pin and/or pad entities */ pin_number = 1; for (i = 0; (i < number_of_rows); i++) /* one row at a time [A .. ZZ ..] etc. * where i is one or more letters of the alphabet, * excluding "I", "O", "Q", "S" and "Z" */ { for (j = 0; (j < number_of_columns); j++) /* all columns of a row [1 .. n] * where j is a member of the positive Natural numbers (N) */ { if (pin1_square && (pin_number == 1)) pin_pad_flags = g_strdup ("square"); else pin_pad_flags = g_strdup (""); pin_pad_name = g_strdup_printf ("%s%d", (row_letters[i]), (j + 1)); if (get_pin_pad_exception (pin_pad_name)) { write_pin ( pin_number, /* pin number */ pin_pad_name, /* pin name */ multiplier * ((((- number_of_columns -1) / 2.0) + 1 + j) * pitch_x), /* x0 coordinate */ multiplier * ((((-number_of_rows - 1) / 2.0) + 1 + i) * pitch_y), /* y0-coordinate */ multiplier * pad_diameter, /* width of the annulus ring (pad) */ multiplier * pad_clearance, /* clearance */ multiplier * (pad_diameter + pad_solder_mask_clearance), /* solder mask clearance */ multiplier * pin_drill_diameter, /* pin drill diameter */ pin_pad_flags /* flags */ ); } pin_number++; } } /* Write a package body on the silkscreen */ if (silkscreen_package_outline) { fprintf (fp, "# Write a package body on the silkscreen\n"); write_rectangle ( multiplier * (-package_body_length / 2.0), multiplier * (-package_body_width / 2.0), multiplier * (package_body_length / 2.0), multiplier * (package_body_width / 2.0), multiplier * silkscreen_line_width ); } /* Write a pin #1 marker on the silkscreen */ if (silkscreen_indicate_1) { fprintf (fp, "# Write a pin 1 marker on the silkscreen\n"); for (dx = 0.0; dx < (pitch_x / 2.0); dx = dx + silkscreen_line_width) { write_element_line ( multiplier * (-package_body_length / 2.0), multiplier * ((-package_body_width / 2.0) + dx), multiplier * ((-package_body_length / 2.0) + dx), multiplier * (-package_body_width / 2.0), multiplier * (silkscreen_line_width) ); } } /* Write a courtyard on the silkscreen */ if (courtyard) { fprintf (fp, "# Write a courtyard on the silkscreen\n"); write_rectangle ( xmin, /* already in mil/100 */ ymin, /* already in mil/100 */ xmax, /* already in mil/100 */ ymax, /* already in mil/100 */ multiplier * courtyard_line_width ); } /* Write attributes to the footprint file. */ if (attributes_in_footprint) { write_attributes (); } /* Finishing touch. */ fprintf (fp, "\n"); fprintf (fp, ")\n"); fclose (fp); /* We are ready creating a footprint. */ if (verbose) { g_log ("", G_LOG_LEVEL_INFO, _("wrote a footprint for a %s package: %s."), footprint_type, footprint_filename); } return (EXIT_SUCCESS); }
/*! * \brief Write a TH footprint for a DIOAD package. * * \return \c EXIT_FAILURE when errors were encountered, * \c EXIT_SUCCESS when OK. */ int dioad_write_footprint () { gdouble xmax; gdouble xmin; gdouble ymax; gdouble ymin; gdouble x_text; gdouble y_text; gdouble dx; gchar *pin_pad_flags = g_strdup (""); /* Attempt to open a file with write permission. */ fp = fopen (footprint_filename, "w"); if (!fp) { g_log ("", G_LOG_LEVEL_WARNING, (_("could not open file for %s footprint: %s.")), footprint_type, footprint_filename); fclose (fp); return (EXIT_FAILURE); } /* Print a license if requested. */ if (license_in_footprint) { write_license (); } /* Determine (extreme) courtyard dimensions based on pin/pad * properties */ if (pad_shapes_type == ROUND_ELONGATED) { xmin = multiplier * ( (-pitch_x / 2.0) - (pad_length / 2.0) - pad_solder_mask_clearance ); xmax = multiplier * ( (pitch_x / 2.0) + (pad_length / 2.0) + pad_solder_mask_clearance ); ymin = multiplier * ( (-pitch_y / 2.0) - (pad_width / 2.0) - pad_solder_mask_clearance ); ymax = multiplier * ( (pitch_y / 2.0) + (pad_width / 2.0) + pad_solder_mask_clearance ); } else { xmin = multiplier * ( (-pitch_x / 2.0) - (pad_diameter / 2.0) - pad_solder_mask_clearance ); xmax = multiplier * ( (pitch_x / 2.0) + (pad_diameter / 2.0) + pad_solder_mask_clearance ); ymin = multiplier * ( (-pitch_y / 2.0) - (pad_diameter / 2.0) - pad_solder_mask_clearance ); ymax = multiplier * ( (pitch_y / 2.0) + (pad_diameter / 2.0) + pad_solder_mask_clearance ); } /* Determine (extreme) courtyard dimensions based on package * properties */ if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin) { xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)); } if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax) { xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)); } if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin) { ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)); } if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax) { ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)); } /* If the user input is using even more real-estate then use it */ if (multiplier * (-courtyard_length / 2.0) < xmin) { xmin = multiplier * (-courtyard_length / 2.0); } if (multiplier * (courtyard_length / 2.0) > xmax) { xmax = multiplier * (courtyard_length / 2.0); } if (multiplier * (-courtyard_width / 2.0) < ymin) { ymin = multiplier * (-courtyard_width / 2.0); } if (multiplier * (courtyard_width / 2.0) > ymax) { ymax = multiplier * (courtyard_width / 2.0); } /* Write element header * Guess for a place where to put the refdes text */ x_text = 0.0 ; /* already in mil/100 */ y_text = (ymin - 10000.0); /* already in mil/100 */ write_element_header (x_text, y_text); /* Write pin and/or pad entities */ if (pad_shapes_type == SQUARE) { pin_pad_flags = g_strdup ("square"); } else if (pad_shapes_type == OCTAGONAL) { pin_pad_flags = g_strdup ("octagon"); } else { pin_pad_flags = g_strdup (""); } write_pin ( 2, /* pin number */ "A", /* pin name */ multiplier * ((pitch_x + pad_diameter) / 2.0), /* x0 coordinate */ 0, /* y0-coordinate */ multiplier * pad_diameter, /* width of the annulus ring (pad) */ multiplier * pad_clearance, /* clearance */ multiplier * (pad_diameter + pad_solder_mask_clearance), /* solder mask clearance */ multiplier * pin_drill_diameter, /* pin drill diameter */ pin_pad_flags /* flags */ ); /* Overrule previous settings in favour of pin 1 square setting */ if (pin1_square) { pin_pad_flags = g_strdup ("square"); } write_pin ( 1, /* pin number */ "C", /* pin name */ multiplier * ((-pitch_x - pad_diameter) / 2.0), /* x0 coordinate */ 0, /* y0-coordinate */ multiplier * pad_diameter, /* width of the annulus ring (pad) */ multiplier * pad_clearance, /* clearance */ multiplier * (pad_diameter + pad_solder_mask_clearance), /* solder mask clearance */ multiplier * pin_drill_diameter, /* pin drill diameter */ pin_pad_flags /* flags */ ); if (pad_shapes_type == ROUND_ELONGATED) { /* Add pads on component side */ pin_pad_flags = g_strdup (""); write_pad ( 1, /* pad number */ "C", /* pad name */ multiplier * ((-pitch_x - pad_length + pad_width) / 2.0), /* x0 coordinate */ 0, /* y0-coordinate */ multiplier * ((-pitch_x + pad_length - pad_width) / 2.0), /* x1 coordinate */ 0, /* y1-coordinate */ multiplier * pad_width, /* width of the pad */ multiplier * pad_clearance, /* clearance */ multiplier * (pad_width + (2 * pad_solder_mask_clearance)), /* solder mask clearance */ pin_pad_flags /* flags */ ); write_pad ( 2, /* pad number */ "A", /* pad name */ multiplier * ((pitch_x - pad_length + pad_width) / 2.0), /* x0 coordinate */ 0, /* y0-coordinate */ multiplier * ((pitch_x + pad_length - pad_width) / 2.0), /* x1 coordinate */ 0, /* y1-coordinate */ multiplier * pad_width, /* width of the pad */ multiplier * pad_clearance, /* clearance */ multiplier * ((pad_length > pad_width ? pad_width : pad_length) + (2 * pad_solder_mask_clearance)), /* solder mask clearance */ pin_pad_flags /* flags */ ); /* Add pads on solder side */ pin_pad_flags = g_strdup ("onsolder"); write_pad ( 1, /* pad number */ "C", /* pad name */ multiplier * ((-pitch_x - pad_length + pad_width) / 2.0), /* x0 coordinate */ 0, /* y0-coordinate */ multiplier * ((-pitch_x + pad_length - pad_width) / 2.0), /* x1 coordinate */ 0, /* y1-coordinate */ multiplier * pad_width, /* width of the pad */ multiplier * pad_clearance, /* clearance */ multiplier * (pad_width + (2 * pad_solder_mask_clearance)), /* solder mask clearance */ pin_pad_flags /* flags */ ); write_pad ( 2, /* pad number */ "A", /* pad name */ multiplier * ((pitch_x - pad_length + pad_width) / 2.0), /* x0 coordinate */ 0, /* y0-coordinate */ multiplier * ((pitch_x + pad_length - pad_width) / 2.0), /* x1 coordinate */ 0, /* y1-coordinate */ multiplier * pad_width, /* width of the pad */ multiplier * pad_clearance, /* clearance */ multiplier * ((pad_length > pad_width ? pad_width : pad_length) + (2 * pad_solder_mask_clearance)), /* solder mask clearance */ pin_pad_flags /* flags */ ); } /* Write package body on silkscreen */ if (silkscreen_package_outline) { fprintf (fp, (_("# Write a package body on the silkscreen\n"))); write_rectangle ( multiplier * (-package_body_length / 2.0), multiplier * (-package_body_width / 2.0), multiplier * (package_body_length / 2.0), multiplier * (package_body_width / 2.0), multiplier * silkscreen_line_width ); /* Now draw some leads if available real estate allows for it. */ if (package_body_length < ((pitch_x - pad_diameter - pad_solder_mask_clearance) / 2.0) - silkscreen_line_width) { write_element_line ( multiplier * (package_body_length / 2.0), 0, multiplier * (((pitch_x - pad_diameter - pad_solder_mask_clearance) / 2.0) - silkscreen_line_width), 0, multiplier * silkscreen_line_width ); write_element_line ( multiplier * (-package_body_length / 2.0), 0, multiplier * (((-pitch_x + pad_diameter + pad_solder_mask_clearance) / 2.0) + silkscreen_line_width), 0, multiplier * silkscreen_line_width ); } } /* Write a pin #1 marker on the silkscreen */ if (silkscreen_indicate_1) { for (dx = 0.0; dx = (3.0 * silkscreen_line_width); dx = dx + silkscreen_line_width) { write_element_line ( multiplier * ((-package_body_length / 2.0) + dx), multiplier * (package_body_width / 2.0) , multiplier * ((-package_body_length / 2.0) + dx), multiplier * (-package_body_width / 2.0), multiplier * silkscreen_line_width ); } } /* Write a courtyard on the silkscreen */ if (courtyard) { fprintf (fp, (_("# Write a courtyard on the silkscreen\n"))); write_rectangle ( xmin, /* already in mil/100 */ ymin, /* already in mil/100 */ xmax, /* already in mil/100 */ ymax, /* already in mil/100 */ multiplier * courtyard_line_width ); } /* Write attributes to the footprint file. */ if (attributes_in_footprint) { write_attributes (); } /* Finishing touch. */ fprintf (fp, "\n"); fprintf (fp, ")\n"); fclose (fp); /* We are ready creating a footprint. */ if (verbose) { g_log ("", G_LOG_LEVEL_INFO, (_("wrote a footprint for a %s package: %s.")), footprint_type, footprint_filename); } return (EXIT_SUCCESS); }
void ethernet_off() { eth_shutdown(); // write_pin(ETH_POWER_EN_PIN, false); write_pin(ETH_NRST_PIN, false); }
void progfault(int err) { write_pin(LED3_PIN, true); while(1); }
void Blinker::blink() { toggle=!toggle; write_pin(pinid, toggle); }
void rs485_switch_transmitter(bool is_on) { write_pin(&PORTD, PORTD4, (uint8_t) is_on); }
void sparrow_init() { //First: Turn off external power blocks set_digital_output(BOOST_5V_EN_PIN); write_pin(BOOST_5V_EN_PIN, false); set_digital_output(PORT_5V_EN_PIN); write_pin(PORT_5V_EN_PIN, false); //TODO: Disable 5V USB generation (USB0_PPWR, P2_0) //TODO: Set fault input interrupt handlers to shutdown peripheral and react accordingly //E.g. USB_PWR_FAULT_HANDLER (P2_1) set_digital_output(AUDIO_POWER_EN_PIN); write_pin(AUDIO_POWER_EN_PIN, false); set_digital_output(WIFI_POWER_EN_PIN ); write_pin(WIFI_POWER_EN_PIN, false ); //TODO: Why does this pin not work? For now, the input pullup keeps the eth domain powered up permamently. //Setting OUT and writing this bit caused the device to hang. Might be correct now, check again. // set_digital_output(ETH_POWER_EN_PIN); write_pin(ETH_POWER_EN_PIN, false); //Set all ext devices to !reset set_digital_output(AUDIO_NRESET); write_pin(AUDIO_NRESET, false); //init base clock to xtal, main clock, via pll1 clock_set_xtal_core_freq(MAIN_CLOCK_MHZ/XTAL_MHZ, 1); //enable derived base clocks for shared use. Dedicated clocks are enabled by the //respective peripheral interface clock_set_source(BASE_APB1_CLK, true, CLKSRC_PLL1); //I2C0 clock_set_source(BASE_APB3_CLK, true, CLKSRC_PLL1); //I2C1 //GPIO set_digital_output(LED1_PIN); set_digital_output(LED2_PIN); set_digital_output(LED3_PIN); set_digital_input(BUTTON_PIN, true, false, false); write_pin(LED1_PIN, false); write_pin(LED2_PIN, false); write_pin(LED3_PIN, false); //I2C i2c_configure_pin(I2C1_SDA_PIN_GROUP, I2C1_SDA_PIN_IDX, I2C1_SDA_PIN_MODE); i2c_configure_pin(I2C1_SCL_PIN_GROUP, I2C1_SCL_PIN_IDX, I2C1_SCL_PIN_MODE); i2c_init(0, I2C_MODE_FAST); i2c_init(1, I2C_MODE_FAST); //TODO: I2C1 might also be used as GPIOs //SPI scu_set_pin(SPI0_MISO_GROUP, SPI0_MISO_IDX, SPI0_MISO_MODE, false, false, true, true, true); scu_set_pin(SPI0_MOSI_GROUP, SPI0_MOSI_IDX, SPI0_MOSI_MODE, false, false, true, false, true); scu_set_pin(SPI0_SCK_GROUP, SPI0_SCK_IDX, SPI0_SCK_MODE, false, false, true, false, true); scu_set_pin(SPI0_SSEL_GROUP, SPI0_SSEL_IDX, SPI0_SSEL_MODE, false, false, true, false, true); scu_set_pin(SPI1_MISO_GROUP, SPI1_MISO_IDX, SPI1_MISO_MODE, false, false, true, true, true); scu_set_pin(SPI1_MOSI_GROUP, SPI1_MOSI_IDX, SPI1_MOSI_MODE, false, false, true, false, true); scu_set_pin(SPI1_SCK_GROUP, SPI1_SCK_IDX, SPI1_SCK_MODE, false, false, true, false, true); scu_set_pin(SPI1_SSEL_GROUP, SPI1_SSEL_IDX, SPI1_SSEL_MODE, false, false, true, false, true); //I2S i2s_configure_pin(I2S0_TX_MCLK_GROUP, I2S0_TX_MCLK_IDX, I2S0_TX_MCLK_MODE); i2s_configure_pin(I2S0_TX_WS_GROUP, I2S0_TX_WS_IDX, I2S0_TX_WS_MODE); i2s_configure_pin(I2S0_TX_SCK_GROUP, I2S0_TX_SCK_IDX, I2S0_TX_SCK_MODE); i2s_configure_pin(I2S0_TX_SD_GROUP, I2S0_TX_SD_IDX, I2S0_TX_SD_MODE); //i2s_configure_pin(I2S0_RX_MCLK_GROUP, I2S0_RX_MCLK_IDX, I2S0_RX_MCLK_MODE); //i2s_configure_pin(I2S0_RX_WS_GROUP, I2S0_RX_WS_IDX, I2S0_RX_WS_MODE); //i2s_configure_pin(I2S0_RX_SCK_GROUP, I2S0_RX_SCK_IDX, I2S0_RX_SCK_MODE); //i2s_configure_pin(I2S0_RX_SD_GROUP, I2S0_RX_SD_IDX, I2S0_RX_SD_MODE); //SD scu_set_pin_mode(SD_CD_GROUP, SD_CD_PIN, SD_CD_MODE); scu_enable_pin_in_buffer(SD_CD_GROUP, SD_CD_PIN, true); scu_set_pin_mode(SD_WP_GROUP, SD_WP_PIN, SD_WP_MODE); //TODO: configure WP pin scu_set_pin_mode(SD_CMD_GROUP, SD_CMD_PIN, SD_CMD_MODE); scu_set_pin_pullup(SD_CMD_GROUP, SD_CMD_PIN, true); scu_enable_pin_in_buffer(SD_CMD_GROUP, SD_CMD_PIN, true); scu_set_pin_mode(SD_D0_GROUP, SD_D0_PIN, SD_D0_MODE); scu_set_pin_pullup(SD_D0_GROUP, SD_D0_PIN, true); scu_enable_pin_in_buffer(SD_D0_GROUP, SD_D0_PIN, true); scu_set_pin_mode(SD_D1_GROUP, SD_D1_PIN, SD_D1_MODE); scu_set_pin_pullup(SD_D1_GROUP, SD_D1_PIN, true); scu_enable_pin_in_buffer(SD_D1_GROUP, SD_D1_PIN, true); scu_set_pin_mode(SD_D2_GROUP, SD_D2_PIN, SD_D2_MODE); scu_set_pin_pullup(SD_D2_GROUP, SD_D2_PIN, true); scu_enable_pin_in_buffer(SD_D2_GROUP, SD_D2_PIN, true); scu_set_pin_mode(SD_D3_GROUP, SD_D3_PIN, SD_D3_MODE); scu_set_pin_pullup(SD_D3_GROUP, SD_D3_PIN, true); scu_enable_pin_in_buffer(SD_D3_GROUP, SD_D3_PIN, true); scu_set_clock_pin_mode(SD_CLK_CLK, SD_CLK_MODE, false, false, true, false, false); //Ethernet RMII creg_init(); creg_set_eth_interface(true); scu_set_clock_pin_mode(ETH_CLK_CLK, ETH_CLK_MODE, false, false, true, true, false); scu_set_pin(ETH_RXD0_GROUP, ETH_RXD0_PIN, ETH_RXD0_MODE, false, false, true, true, false); scu_set_pin(ETH_RXD1_GROUP, ETH_RXD1_PIN, ETH_RXD1_MODE, false, false, true, true, false); scu_set_pin(ETH_TXD0_GROUP, ETH_TXD0_PIN, ETH_TXD0_MODE, false, false, true, false, false); scu_set_pin(ETH_TXD1_GROUP, ETH_TXD1_PIN, ETH_TXD1_MODE, false, false, true, false, false); scu_set_pin(ETH_MDC_GROUP, ETH_MDC_PIN, ETH_MDC_MODE, false, false, true, false, false); scu_set_pin(ETH_TXEN_GROUP, ETH_TXEN_PIN, ETH_TXEN_MODE, false, false, true, false, false); scu_set_pin(ETH_CRS_DV_GROUP, ETH_CRS_DV_PIN, ETH_CRS_DV_MODE, false, false, true, true, false); scu_set_pin(ETH_MDIO_GROUP, ETH_MDIO_PIN, ETH_MDIO_MODE, false, false, true, true, false); set_digital_input(ETH_NINT_PIN, true, false, true); set_digital_output(ETH_NRST_PIN); write_pin(ETH_NRST_PIN, false); //put into reset //CC3000 WIFI set_digital_output(CC3000_SW_EN_PIN); write_pin(CC3000_SW_EN_PIN, false); set_digital_input(CC3000_IRQ_PIN, false, false, true); }
void control_led(char value) { set_direction_pin(DDR_ADDR(CONFIG_MOTOR_PORT), CONFIG_LED_PIN_NO, 1); write_pin(PORT_ADDR(CONFIG_MOTOR_PORT), CONFIG_LED_PIN_NO, value); }
void wifi_off() { wifi_shutdown(); write_pin(CC3000_SW_EN_PIN, false); write_pin(WIFI_POWER_EN_PIN, false); }