[an error occurred while processing this directive]
Исходники "xmodem" (XY-Modem) подойдут? (внутрях С-ишный огрызок для AVR)
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено Мегавольт 27 июня 2006 г. 10:43
В ответ на: Ищу примеры работы с флэшкой AT45DB на С. Желательно через SPI AVR. отправлено <font color=gray>Vladimir Ljaschko</font> 27 июня 2006 г. 10:29

// GetDeviceDensity.c
// gets the device density and updates the global
// variables pages with the number of pages in the device and page_size
// with the number of bytes in a buffer

#include "xmodem.h"

extern unsigned int pages; // number of pages in device
extern unsigned int page_size; // page size for device

// function prototypes
void WriteByte(unsigned char byte);

void GetDeviceDensity(void) {

unsigned char dataflash_density; // spi status register contents

// bring CS on dataflash low for status register read
PORTB &= ~((1 << DFCS));

// now read the status register ... it contains the compare status
// issue status register read
WriteByte(STATUS_REGISTER);

WriteByte(0xff); // have to write a byte to get it back ... full duplex
dataflash_density = SPDR; // read the status

// bring CS on dataflash high
PORTB |= (1 << DFCS);

dataflash_density = ((dataflash_density >> 3) & 0x07);

// decode pages and page_size from device density
switch (dataflash_density) {

case (1) : pages = 512; // 1M
page_size = 264;
break;
case (2) : pages = 1024; // 2M
page_size = 264;
break;
case (3) : pages = 2048; // 4M
page_size = 264;
break;
case (4) : pages = 4096; // 8M
page_size = 264;
break;
case (5) : pages = 4096; // 16M
page_size = 528;
break;
case (6) : pages = 8192; // 32M
page_size = 528;
break;
}
}

Составить ответ  |||  Конференция  |||  Архив

Ответы


Отправка ответа

Имя (обязательно): 
Пароль: 
E-mail: 
NoIX ключ Запомнить

Тема (обязательно):
Сообщение:

Ссылка на URL: 
Название ссылки: 

URL изображения: 


Rambler's Top100 Рейтинг@Mail.ru
Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание

E-mail: info@telesys.ru