/* * Copyright Droids Corporation, Microb Technology, Eirbot (2005) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Revision : $Id$ * */ #include #include #include #include #include #include #include #define SOH 0x01 #define NAK 0x15 #define ACK 0x06 #define EOT 0x04 #define CTRLZ 26 #define BASE_RAMV 0x00000000 #define BASE_RAMT 0x00100000 #define BASE_FLASHA 0x00200000 #define BASE_FLASHB 0x00300000 u08 xmodem_send(u32 memory_address, u32 taille); void* mem2add(u32 memory_address) { void *pointeur; unsigned char *pages = (unsigned char *) (0x1FFF); // memory_address 22 bits: // 31 downto 22: rien donc 0 // 21 downto 20: pages (00=ramV, 01=ramT, 10=flashA, 11=flashB) // 19 downto 1: adresse physique // 0 : poids fort / faible (dans le cas des flash, poids forts et faibles accedent a la meme addresse) // "*pages": // 7 inutilisé // 6 downto 5: pages donc 21 downto 20 // 4 downto 0: adresse haute donc 19 downto 15 *pages = (memory_address & 0x003F8000) >> 15; pointeur = (void*)((u16)(memory_address & 0x00007FFF) + (u16)0x00008000); return pointeur; } void mem_fill(u32 memory_address, u08 data, u32 taille) { u08 *buffer; u32 cpt; for (cpt=0; cpt= 0) { crc = crc ^ (int) *ptr++ << 8; i = 8; do { if (crc & 0x8000) crc = crc << 1 ^ 0x1021; else crc = crc << 1; } while(--i); } return (crc); } void set_pixel(u08 ligne, u08 pixel, u08 etat) { // Résolution minimale (comme la croix) // 4 pixels par 2 lignes u16 add; u08 *overlay; u08 which; add = (pixel >> 3) + (ligne << 5); printf("(%d)\r\n", add); which = pixel&0x07; // Numéro du bit à toucher overlay = (u08*)(0x2000 + add); if (etat == 0) *overlay &= ~(1<>8)); uart0_send((u08)(crc & 0x00FF)); octet = uart0_recv(); if (octet == ACK) { bloc_num++; //if (bloc_num == 255) bloc_num=1; } else { memory_address -= 128; nombre -= 128; } } while (nombre <= taille); uart0_send(EOT); uart0_recv(); return 0; }