00001
00026 #include "register_functions.c"
00027 #include "con_hdr.h"
00028
00029
00039 int
00040 con_hdr_create_packages_list ()
00041 {
00042 g_list_free (packages_list);
00043 packages_list = g_list_append (packages_list, "CON-DIP");
00044 return (EXIT_SUCCESS);
00045 }
00046
00047
00074 int
00075 con_hdr_drc ()
00076 {
00077 int result = EXIT_SUCCESS;
00078 if (verbose)
00079 {
00080 g_log ("", G_LOG_LEVEL_INFO,
00081 _("[%s] DRC Check: checking package %s."),
00082 footprint_type, footprint_name);
00083 }
00084
00085 if (number_of_pins = 0)
00086 {
00087 if (verbose)
00088 {
00089 g_log ("", G_LOG_LEVEL_WARNING,
00090 (_("[%s] DRC Error: total number of pins is 0.")),
00091 footprint_type);
00092 }
00093 result = EXIT_FAILURE;
00094 }
00095
00096 if (number_of_rows < 2)
00097 {
00098 if (verbose)
00099 {
00100 g_log ("", G_LOG_LEVEL_WARNING,
00101 (_("[%s] DRC Error: number of rows < 2.")),
00102 footprint_type);
00103 }
00104 result = EXIT_FAILURE;
00105 }
00106
00107 if (number_of_columns <= 2)
00108 {
00109 if (verbose)
00110 {
00111 g_log ("", G_LOG_LEVEL_WARNING,
00112 (_("[%s] DRC Error: number of columns is not greater than, or equal to, 2.")),
00113 footprint_type);
00114 }
00115 number_of_columns = 2;
00116 result = EXIT_FAILURE;
00117 }
00118
00119 switch (pad_shapes_type)
00120 {
00121 case NO_SHAPE:
00122 {
00123 if (verbose)
00124 {
00125 g_log ("", G_LOG_LEVEL_WARNING,
00126 (_("[%s] DRC Error: NO_SHAPE specified for check for allowed pad shapes.")),
00127 footprint_type);
00128 }
00129 result = EXIT_FAILURE;
00130 break;
00131 }
00132 case ROUND:
00133 {
00134 break;
00135 }
00136 case SQUARE:
00137 {
00138 break;
00139 }
00140 case OCTAGONAL:
00141 {
00142 if (verbose)
00143 {
00144 g_log ("", G_LOG_LEVEL_WARNING,
00145 (_("[%s] DRC Error: octagonal pad shape specified for check for allowed pad shapes.")),
00146 footprint_type);
00147 }
00148 result = EXIT_FAILURE;
00149 break;
00150 }
00151 case ROUND_ELONGATED:
00152 {
00153 if (verbose)
00154 {
00155 g_log ("", G_LOG_LEVEL_WARNING,
00156 (_("[%s] DRC Error: round elongated pad shape specified for check for allowed pad shapes.")),
00157 footprint_type);
00158 }
00159 result = EXIT_FAILURE;
00160 break;
00161 }
00162 default:
00163 {
00164 if (verbose)
00165 {
00166 g_log ("", G_LOG_LEVEL_WARNING,
00167 (_("[%s] DRC Error: no valid pad shape type specified.")),
00168 footprint_type);
00169 }
00170 result = EXIT_FAILURE;
00171 break;
00172 }
00173 }
00174
00175 if (package_body_length <= 0.0)
00176 {
00177 if (verbose)
00178 {
00179 g_log ("", G_LOG_LEVEL_WARNING,
00180 (_("[%s] DRC Error: specified package body length is too small.")),
00181 footprint_type);
00182 }
00183 result = EXIT_FAILURE;
00184 }
00185 if (package_body_width <= 0.0)
00186 {
00187 if (verbose)
00188 {
00189 g_log ("", G_LOG_LEVEL_WARNING,
00190 (_("[%s] DRC Error: specified package body width is too small.")),
00191 footprint_type);
00192 }
00193 result = EXIT_FAILURE;
00194 }
00195 if (package_body_height <= 0.0)
00196 {
00197 if (verbose)
00198 {
00199 g_log ("", G_LOG_LEVEL_WARNING,
00200 (_("[%s] DRC Error: specified package body height is too small.")),
00201 footprint_type);
00202 }
00203 result = EXIT_FAILURE;
00204 }
00205
00206 if (courtyard_length <= 0.0)
00207 {
00208 if (verbose)
00209 {
00210 g_log ("", G_LOG_LEVEL_WARNING,
00211 (_("[%s] DRC Error: specified courtyard length is too small.")),
00212 footprint_type);
00213 }
00214 result = EXIT_FAILURE;
00215 }
00216 if (courtyard_width <= 0.0)
00217 {
00218 if (verbose)
00219 {
00220 g_log ("", G_LOG_LEVEL_WARNING,
00221 (_("[%s] DRC Error: specified courtyard width is too small.")),
00222 footprint_type);
00223 }
00224 result = EXIT_FAILURE;
00225 }
00226
00227 if (pitch_x - pad_diameter < pad_clearance)
00228 {
00229 if (verbose)
00230 {
00231 g_log ("", G_LOG_LEVEL_WARNING,
00232 (_("[%s] DRC Error: minimum clearance between copper (X-direction) is too small.")),
00233 footprint_type);
00234 }
00235 result = EXIT_FAILURE;
00236 }
00237 if (pitch_x - pad_length < pad_clearance)
00238 {
00239 if (verbose)
00240 {
00241 g_log ("", G_LOG_LEVEL_WARNING,
00242 (_("[%s] DRC Error: minimum clearance between copper (X-direction) is too small.")),
00243 footprint_type);
00244 }
00245 result = EXIT_FAILURE;
00246 }
00247
00248 if (pitch_y - pad_diameter < pad_clearance)
00249 {
00250 if (verbose)
00251 {
00252 g_log ("", G_LOG_LEVEL_WARNING,
00253 (_("[%s] DRC Error: minimum clearance between copper (Y-direction) is too small.")),
00254 footprint_type);
00255 }
00256 result = EXIT_FAILURE;
00257 }
00258 if (pitch_y - pad_width < pad_clearance)
00259 {
00260 if (verbose)
00261 {
00262 g_log ("", G_LOG_LEVEL_WARNING,
00263 (_("[%s] DRC Error: minimum clearance between copper (Y-direction) is too small.")),
00264 footprint_type);
00265 }
00266 result = EXIT_FAILURE;
00267 }
00268
00269 if (fiducial)
00270 {
00271 if (verbose)
00272 {
00273 g_log ("", G_LOG_LEVEL_WARNING,
00274 (_("[%s] DRC Error: package should not have any fiducials.")),
00275 footprint_type);
00276 }
00277 result = EXIT_FAILURE;
00278 }
00279
00280
00281 if (package_body_length - courtyard_length < courtyard_clearance_with_package)
00282 {
00283 if (verbose)
00284 {
00285 g_log ("", G_LOG_LEVEL_WARNING,
00286 (_("[%s] DRC Error: clearance of the package length with regard to the courtyard dimensions is too small.")),
00287 footprint_type);
00288 }
00289 result = EXIT_FAILURE;
00290 }
00291
00292
00293 if (package_body_width - courtyard_width < courtyard_clearance_with_package)
00294 {
00295 if (verbose)
00296 {
00297 g_log ("", G_LOG_LEVEL_WARNING,
00298 (_("[%s] DRC Error: clearance of the package width with regard to the courtyard dimensions is too small.")),
00299 footprint_type);
00300 }
00301 result = EXIT_FAILURE;
00302 }
00308
00309 if (silkscreen_package_outline && (silkscreen_line_width == 0.0))
00310 {
00311 if (verbose)
00312 {
00313 g_log ("", G_LOG_LEVEL_WARNING,
00314 (_("[%s] DRC Error: silkscreen line width is too small.")),
00315 footprint_type);
00316 }
00317 result = EXIT_FAILURE;
00318 }
00319 switch (units_type)
00320 {
00321 case NO_UNITS:
00322 {
00323 if (verbose)
00324 {
00325 g_log ("", G_LOG_LEVEL_WARNING,
00326 (_("[%s] DRC Error: no units specified.")),
00327 footprint_type);
00328 }
00329 result = EXIT_FAILURE;
00330 break;
00331 }
00332 case MIL:
00333 if (silkscreen_package_outline && (silkscreen_line_width > 40.0))
00334 {
00335 if (verbose)
00336 {
00337 g_log ("", G_LOG_LEVEL_WARNING,
00338 (_("[%s] DRC Error: silkscreen line width too wide.")),
00339 footprint_type);
00340 }
00341 result = EXIT_FAILURE;
00342 break;
00343 }
00344 case MIL_100:
00345 if (silkscreen_package_outline && (silkscreen_line_width > 4000.0))
00346 {
00347 if (verbose)
00348 {
00349 g_log ("", G_LOG_LEVEL_WARNING,
00350 (_("[%s] DRC Error: silkscreen line width too wide.")),
00351 footprint_type);
00352 }
00353 result = EXIT_FAILURE;
00354 break;
00355 }
00356 case MM:
00357 if (silkscreen_package_outline && (silkscreen_line_width > 1.0))
00358 {
00359 if (verbose)
00360 {
00361 g_log ("", G_LOG_LEVEL_WARNING,
00362 (_("[%s] DRC Error: silkscreen line width too wide.")),
00363 footprint_type);
00364 }
00365 result = EXIT_FAILURE;
00366 break;
00367 }
00368 default:
00369 {
00370 if (verbose)
00371 {
00372 g_log ("", G_LOG_LEVEL_WARNING,
00373 (_("[%s] DRC Error: no valid units type specified.")),
00374 footprint_type);
00375 }
00376 result = EXIT_FAILURE;
00377 break;
00378 }
00379 }
00381
00382 if (verbose && (result == EXIT_SUCCESS))
00383 {
00384 g_log ("", G_LOG_LEVEL_INFO,
00385 (_("[%s] DRC Check: no errors while checking package %s.")),
00386 footprint_type, footprint_name);
00387 }
00388 return (result);
00389 }
00390
00391
00405 int
00406 con_hdr_get_default_footprint_values ()
00407 {
00408 if (!strcmp (footprint_name, "?CON-HDR"))
00409 {
00410 footprint_units = g_strdup ("mil");
00411 package_body_width = 300;
00412 package_body_length = 100;
00413 package_body_height = 200;
00414 package_is_radial = FALSE;
00415 number_of_pins = 4;
00416 number_of_columns = 2;
00417 number_of_rows = 0;
00418 pitch_x = 100;
00419 pitch_y = 100;
00420 count_x = 0;
00421 count_y = 2;
00422 pad_diameter = 60;
00423 pin_drill_diameter = 28;
00424 pad_length = 0.0;
00425 pad_width = 0.00;
00426 pad_shape = g_strdup ("circular pad");
00427 pad_shapes_type = ROUND;
00428 pad_clearance = 15;
00429 pad_solder_mask_clearance = 6;
00430 thermal = FALSE;
00431 thermal_length = 0.0;
00432 thermal_width = 0.0;
00433 fiducial = FALSE;
00434 fiducial_pad_diameter = 0.00;
00435 fiducial_pad_solder_mask_clearance = 0.00;
00436 silkscreen_package_outline = TRUE;
00437 silkscreen_length = 0.00;
00438 silkscreen_width = 0.00;
00439 silkscreen_line_width = 0.20;
00440 courtyard = FALSE;
00441 courtyard_length = 0.00;
00442 courtyard_width = 0.00;
00443 courtyard_line_width = 0.05;
00444 g_free (footprint_name);
00445 footprint_name = g_strdup ("CON-HDR");
00446 return (EXIT_SUCCESS);
00447 }
00448 else
00449 {
00450 fprintf (stderr,
00451 _("WARNING: default values for footprint %s not found.\n"),
00452 footprint_name);
00453 return (EXIT_FAILURE);
00454 }
00455 return (EXIT_SUCCESS);
00456 }
00457
00458
00466 #if GUI
00467 int
00468 con_hdr_set_gui_constraints ()
00469 {
00470
00471 GtkWidget *package_is_radial_checkbutton = lookup_widget (GTK_WIDGET (widget),
00472 "package_is_radial_checkbutton");
00473 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (package_is_radial_checkbutton), FALSE);
00474 gtk_widget_set_sensitive (package_is_radial_checkbutton, FALSE);
00475
00476
00477 GtkWidget *number_total_pins_entry = lookup_widget (GTK_WIDGET (widget),
00478 "number_total_pins_entry");
00479 gtk_widget_set_sensitive (number_total_pins_entry, FALSE);
00480 GtkWidget *number_of_columns_entry = lookup_widget (GTK_WIDGET (widget),
00481 "number_of_columns_entry");
00482 gtk_entry_set_text (GTK_ENTRY (number_of_columns_entry), "");
00483 gtk_widget_set_sensitive (number_of_columns_entry, FALSE);
00484 GtkWidget *number_of_rows_entry = lookup_widget (GTK_WIDGET (widget),
00485 "number_of_rows_entry");
00486 gtk_entry_set_text (GTK_ENTRY (number_of_rows_entry), "");
00487 gtk_widget_set_sensitive (number_of_rows_entry, TRUE);
00488 GtkWidget *count_x_entry = lookup_widget (GTK_WIDGET (widget),
00489 "count_x_entry");
00490 gtk_entry_set_text (GTK_ENTRY (count_x_entry), "");
00491 gtk_widget_set_sensitive (count_x_entry, TRUE);
00492 GtkWidget *count_y_entry = lookup_widget (GTK_WIDGET (widget),
00493 "count_y_entry");
00494 gtk_entry_set_text (GTK_ENTRY (count_y_entry), "");
00495 gtk_widget_set_sensitive (count_y_entry, FALSE);
00496 GtkWidget *number_1_position_entry = lookup_widget (GTK_WIDGET (widget),
00497 "number_1_position_entry");
00498 gtk_combo_box_set_active (GTK_COMBO_BOX (number_1_position_entry), 1);
00499 gtk_widget_set_sensitive (number_1_position_entry, FALSE);
00500
00501
00502 gui_constraints_disable_thermal_tab_widgets (widget);
00503
00504
00505 gui_constraints_disable_heel_and_toe_goals_tab_widgets (widget);
00506 return (EXIT_SUCCESS);
00507 }
00508 #endif
00509
00510
00527 int
00528 con_hdr_write_footprint ()
00529 {
00530 gdouble xmax;
00531 gdouble xmin;
00532 gdouble ymax;
00533 gdouble ymin;
00534 gdouble x_text;
00535 gdouble y_text;
00536 gint pin_number;
00537 gchar *pin_pad_name = g_strdup ("");
00538 gchar *pin_pad_flags = g_strdup ("");
00539 gint i;
00540 gint j;
00541
00542
00543 fp = fopen (footprint_filename, "w");
00544 if (!fp)
00545 {
00546 g_log ("", G_LOG_LEVEL_WARNING,
00547 _("could not open file for %s footprint: %s."),
00548 footprint_type, footprint_filename);
00549 fclose (fp);
00550 return (EXIT_FAILURE);
00551 }
00552
00553 if (license_in_footprint)
00554 {
00555 write_license ();
00556 }
00557
00558
00559 xmin = multiplier *
00560 (
00561 (((-number_of_columns + 1) / 2.0) * pitch_x) -
00562 (((pad_diameter > pad_length) ? pad_diameter : pad_length) / 2.0) -
00563 pad_solder_mask_clearance
00564 );
00565 xmax = multiplier *
00566 (
00567 (((number_of_columns - 1) / 2.0) * pitch_x) +
00568 (((pad_diameter > pad_length) ? pad_diameter : pad_length) / 2.0) +
00569 pad_solder_mask_clearance
00570 );
00571 ymin = multiplier *
00572 (
00573 (-pitch_y / 2.0) -
00574 (((pad_diameter > pad_width) ? pad_diameter : pad_width) / 2.0) -
00575 pad_solder_mask_clearance
00576 );
00577 ymax = multiplier *
00578 (
00579 (pitch_y / 2.0) +
00580 (((pad_diameter > pad_width) ? pad_diameter : pad_width) / 2.0) +
00581 pad_solder_mask_clearance
00582 );
00583
00584
00585 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
00586 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
00587 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
00588 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
00589 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
00590 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
00591 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
00592 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
00593
00594 if (multiplier * (-courtyard_length / 2.0) < xmin)
00595 xmin = multiplier * (-courtyard_length / 2.0);
00596 if (multiplier * (courtyard_length / 2.0) > xmax)
00597 xmax = multiplier * (courtyard_length / 2.0);
00598 if (multiplier * (-courtyard_width / 2.0) < ymin)
00599 ymin = multiplier * (-courtyard_width / 2.0);
00600 if (multiplier * (courtyard_width / 2.0) > ymax)
00601 ymax = multiplier * (courtyard_width / 2.0);
00602
00603
00604 x_text = 0.0 ;
00605 y_text = (ymin - 10000.0);
00606 write_element_header (x_text, y_text);
00607
00608 pin_number = 1;
00609 for (i = 0; (i < count_x); i++)
00610 {
00611 for (j = 0; (j < number_of_rows); j++)
00612 {
00613 if (pin1_square && (pin_number == 1))
00614 pin_pad_flags = g_strdup ("square");
00615 else
00616 pin_pad_flags = g_strdup ("");
00617 write_pin
00618 (
00619 pin_number,
00620 pin_pad_name,
00621 multiplier * ((((-count_x - 1) / 2.0) + 1 + i) * pitch_x),
00622 multiplier * ((((number_of_rows - 1) / 2.0) + 1 - j) * (pitch_y / 2.0)),
00623 multiplier * pad_diameter,
00624 multiplier * pad_clearance,
00625 multiplier * (pad_diameter + 2 * pad_solder_mask_clearance),
00626 multiplier * pin_drill_diameter,
00627 pin_pad_flags
00628 );
00629 if (!strcmp (pad_shape, "rounded pad, elongated"))
00630 {
00631 if (!strcmp (pin_pad_flags, ""))
00632 pin_pad_flags = g_strconcat (pin_pad_flags, "onsolder", NULL);
00633 else
00634 pin_pad_flags = g_strconcat (pin_pad_flags, ",onsolder", NULL);
00635 write_pad
00636 (
00637 pin_number,
00638 pin_pad_name,
00639 multiplier * ((((-count_x - 1) / 2.0) + 1 + i) * pitch_x),
00640 multiplier * (((((number_of_rows - 1) / 2.0) + 1 - j) * (pitch_y / 2.0)) + pad_length - pad_width) / 2.0,
00641 multiplier * ((((-count_x - 1) / 2.0) + 1 + i) * pitch_x),
00642 multiplier * (((((number_of_rows - 1) / 2.0) + 1 - j) * (pitch_y / 2.0)) - pad_length + pad_width) / 2.0,
00643 multiplier * pad_length,
00644 multiplier * 2 * pad_clearance,
00645 multiplier * (pad_length + (2 * pad_solder_mask_clearance)),
00646 pin_pad_flags
00647 );
00648 }
00649 pin_number++;
00650 }
00651 }
00652
00653 if (silkscreen_package_outline)
00654 {
00655 fprintf (fp, "# Write a package body on the silkscreen\n");
00656 write_rectangle
00657 (
00658 multiplier * ((-package_body_length - silkscreen_line_width) / 2.0) ,
00659 multiplier * ((-package_body_width - silkscreen_line_width) / 2.0) ,
00660 multiplier * ((package_body_length + silkscreen_line_width) / 2.0) ,
00661 multiplier * ((package_body_width + silkscreen_line_width) / 2.0) ,
00662 multiplier * silkscreen_line_width
00663 );
00664 }
00665
00666 if (silkscreen_indicate_1)
00667 {
00668 fprintf (fp, "# Write a pin 1 marker on the silkscreen\n");
00669 write_element_arc
00670 (
00671 xmin - (multiplier * (pad_solder_mask_clearance + pad_clearance)),
00672 ymax + (multiplier * (pad_solder_mask_clearance + pad_clearance)),
00673 multiplier * 0.5 * silkscreen_line_width,
00674 multiplier * 0.5 * silkscreen_line_width,
00675 0,
00676 360,
00677 multiplier * silkscreen_line_width
00678 );
00679 }
00680
00681 if (courtyard)
00682 {
00683 fprintf (fp, "# Write a courtyard on the silkscreen\n");
00684 write_rectangle
00685 (
00686 xmin,
00687 ymin,
00688 xmax,
00689 ymax,
00690 multiplier * courtyard_line_width
00691 );
00692 }
00693
00694 if (attributes_in_footprint)
00695 {
00696 write_attributes ();
00697 }
00698
00699 fprintf (fp, "\n");
00700 fprintf (fp, ")\n");
00701 fclose (fp);
00702
00703 if (verbose)
00704 {
00705 g_log ("", G_LOG_LEVEL_INFO,
00706 _("wrote a footprint for a %s package: %s."),
00707 footprint_type,
00708 footprint_filename);
00709 }
00710 return (EXIT_SUCCESS);
00711 }
00712
00713
00717 static fpw_function_t
00718 con_hdr_function_list[] =
00719 {
00720 #if GUI
00721 {
00722 "Set GUI constraints",
00723 con_hdr_set_gui_constraints,
00724 "Set GUI constraints for a CON-HDR package",
00725 NULL
00726 },
00727 #endif
00728 {
00729 "Create Package List",
00730 con_hdr_create_packages_list,
00731 "Create a list of packages with known values",
00732 NULL
00733 },
00734 {
00735 "Default Element Values",
00736 con_hdr_get_default_footprint_values,
00737 "Get default values for a selected CON-HDR package",
00738 NULL
00739 },
00740 {
00741 "Write footprint",
00742 con_hdr_write_footprint,
00743 "Write footprint for a selected CON-HDR package",
00744 NULL
00745 }
00746 };
00747
00748
00752 REGISTER_FUNCTIONS (con_hdr_function_list)
00753
00754
00755
00758 void
00759 con_hdr_init ()
00760 {
00761 register_con_hdr_function_list ();
00762 }
00763
00764
00765