o: ActiveSupport::Cache::Entry :@compressedF:@value"‰)"ƒ)
| main.c | ||
|---|---|---|
| 11 | 11 |
* PC2 SCK speed option. |
| 12 | 12 |
* GND -> slow (8khz SCK), |
| 13 | 13 |
* open -> software set speed (default is 375kHz SCK) |
| 14 |
* |
|
| 15 |
* 2014_02_09 miho@mlab.cz - cleaned code and defined IO port better, automatic compile prodcess for more target CPUs |
|
| 16 |
* |
|
| 14 | 17 |
*/ |
| 15 | 18 |
|
| 16 | 19 |
#include <avr/io.h> |
| ... | ... | |
| 44 | 47 |
if (data[1] == USBASP_FUNC_CONNECT) {
|
| 45 | 48 |
|
| 46 | 49 |
/* set SCK speed */ |
| 47 |
if ((PINC & (1 << PC2)) == 0) {
|
|
| 50 |
if ((PIN(CLKSW_PORT) & (1 << CLKSW_BIT)) == 0) {
|
|
| 48 | 51 |
ispSetSCKOption(USBASP_ISP_SCK_8); |
| 49 | 52 |
} else {
|
| 50 | 53 |
ispSetSCKOption(prog_sck); |
| ... | ... | |
| 303 | 306 |
int main(void) {
|
| 304 | 307 |
uchar i, j; |
| 305 | 308 |
|
| 306 |
/* no pullups on USB and ISP pins */ |
|
| 307 |
PORTD = 0; |
|
| 308 |
PORTB = 0; |
|
| 309 |
/* all outputs except PD2 = INT0 */ |
|
| 310 |
DDRD = ~(1 << 2); |
|
| 309 |
/* unused pins with pullups */ |
|
| 310 |
PORTB = PORTB_UNUSED_MASK; |
|
| 311 |
PORTC = PORTC_UNUSED_MASK; |
|
| 312 |
PORTD = PORTD_UNUSED_MASK; |
|
| 311 | 313 |
|
| 314 |
/* LED ports as output */ |
|
| 315 |
ledInit(); |
|
| 316 |
ledGreenOn(); |
|
| 317 |
ledRedOff(); |
|
| 318 |
|
|
| 319 |
/* CLKSW input with PullUp (external jumper to GND) */ |
|
| 320 |
clkswInit(); |
|
| 321 |
|
|
| 312 | 322 |
/* output SE0 for USB reset */ |
| 313 |
DDRB = ~0; |
|
| 323 |
DDR(USB_CFG_IOPORTNAME) |= (1 << USB_CFG_DPLUS_BIT | 1<<USB_CFG_DMINUS_BIT); |
|
| 324 |
|
|
| 325 |
/* USB Reset by device only required on Watchdog Reset */ |
|
| 314 | 326 |
j = 0; |
| 315 |
/* USB Reset by device only required on Watchdog Reset */ |
|
| 316 | 327 |
while (--j) {
|
| 317 | 328 |
i = 0; |
| 318 | 329 |
/* delay >10ms for USB reset */ |
| 319 | 330 |
while (--i) |
| 320 | 331 |
; |
| 321 | 332 |
} |
| 333 |
|
|
| 322 | 334 |
/* all USB and ISP pins inputs */ |
| 323 |
DDRB = 0;
|
|
| 335 |
DDR(USB_CFG_IOPORTNAME) &= ~(1 << USB_CFG_DPLUS_BIT | 1<<USB_CFG_DMINUS_BIT);
|
|
| 324 | 336 |
|
| 325 |
/* all inputs except PC0, PC1 */ |
|
| 326 |
DDRC = 0x03; |
|
| 327 |
PORTC = 0xfe; |
|
| 328 |
|
|
| 329 | 337 |
/* init timer */ |
| 330 | 338 |
clockInit(); |
| 331 | 339 |
|
| ... | ... | |
| 337 | 345 |
} |
| 338 | 346 |
return 0; |
| 339 | 347 |
} |
| 340 |
|
|