1383 |
kaklik |
1 |
#include "main.h" |
|
|
2 |
#int_RB |
|
|
3 |
void RB_isr(void) |
|
|
4 |
{ |
|
|
5 |
|
|
|
6 |
} |
|
|
7 |
|
|
|
8 |
#define LCD_ENABLE_PIN PIN_E0 |
|
|
9 |
#define LCD_RS_PIN PIN_E1 |
|
|
10 |
#define LCD_RW_PIN PIN_E2 |
|
|
11 |
#define LCD_DATA4 PIN_D4 |
|
|
12 |
#define LCD_DATA5 PIN_D5 |
|
|
13 |
#define LCD_DATA6 PIN_D6 |
|
|
14 |
#define LCD_DATA7 PIN_D7 |
|
|
15 |
|
|
|
16 |
#include <lcd.c> |
|
|
17 |
|
|
|
18 |
//#define USB_CON_SENSE_PIN PIN_B2 |
|
|
19 |
|
|
|
20 |
// Includes all USB code and interrupts, as well as the CDC API |
|
|
21 |
#include <usb_cdc.h> |
|
|
22 |
|
|
|
23 |
#rom int 0xf00000={1,2,3,4} |
|
|
24 |
|
|
|
25 |
void main() { |
|
|
26 |
int i, j, address, value; |
|
|
27 |
|
|
|
28 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
29 |
setup_adc(ADC_OFF); |
|
|
30 |
setup_psp(PSP_DISABLED); |
|
|
31 |
setup_spi(SPI_SS_DISABLED); |
|
|
32 |
setup_wdt(WDT_OFF); |
|
|
33 |
setup_timer_0(RTCC_INTERNAL); |
|
|
34 |
setup_timer_1(T1_DISABLED); |
|
|
35 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
36 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
|
|
37 |
setup_comparator(NC_NC_NC_NC); |
|
|
38 |
setup_vref(FALSE); |
|
|
39 |
// enable_interrupts(INT_RB); |
|
|
40 |
enable_interrupts(GLOBAL); |
|
|
41 |
|
|
|
42 |
usb_init(); |
|
|
43 |
lcd_init(); |
|
|
44 |
|
|
|
45 |
lcd_gotoxy(1,1); |
|
|
46 |
printf(lcd_putc, "\fReady...\n"); |
|
|
47 |
|
|
|
48 |
while(!usb_cdc_connected()); |
|
|
49 |
|
|
|
50 |
do { |
|
|
51 |
printf(usb_cdc_putc, "\r\n\nEEPROM:\r\n"); // Display contents of the first 64 |
|
|
52 |
for(i=0; i<=3; ++i) { // bytes of the data EEPROM in hex |
|
|
53 |
for(j=0; j<=15; ++j) { |
|
|
54 |
printf(usb_cdc_putc, "%2x ", read_eeprom( i*16+j ) ); |
|
|
55 |
} |
|
|
56 |
printf(usb_cdc_putc, "\n\r"); |
|
|
57 |
} |
|
|
58 |
printf(usb_cdc_putc, "\r\nLocation to change: "); |
|
|
59 |
address = gethex_usb(); |
|
|
60 |
printf(usb_cdc_putc, "\r\nNew value: "); |
|
|
61 |
value = gethex_usb(); |
|
|
62 |
|
|
|
63 |
write_eeprom( address, value ); |
|
|
64 |
|
|
|
65 |
} while (TRUE); |
|
|
66 |
} |