Перейти к содержанию
    

DmitryG

Участник
  • Постов

    7
  • Зарегистрирован

  • Посещение

Репутация

0 Обычный
  1. STM32F4 ETHERNET

    Здравствуйте! Проект: Организация сервера на базе Stm32f4. Добавил в проект HTML файл. Обновил с помощью программы makefsdata файл fsdata.c. Удалил устаревший fsdata.c. Однако, Отладчик ругается, что HTML файлы, загружаемые в память микроконтроллера, инициализированы одновременно в двух файлах. (Error: L6200E: Symbol file__index_html multiply defined (by fs.o and fsdata.o)) Файл fs.c Код #include "lwip/opt.h" #include "lwip/def.h" #include "fs.h" #include "fsdata.h" #include <string.h> /** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the * file system (to prevent changing the file included in CVS) */ #ifndef HTTPD_USE_CUSTUM_FSDATA #define HTTPD_USE_CUSTUM_FSDATA 0 #endif #if HTTPD_USE_CUSTUM_FSDATA #include "fsdata_custom.c" #else /* HTTPD_USE_CUSTUM_FSDATA */ #include "fsdata.c" #endif /* HTTPD_USE_CUSTUM_FSDATA */ /*-----------------------------------------------------------------------------------*/ /* Define the number of open files that we can support. */ #ifndef LWIP_MAX_OPEN_FILES #define LWIP_MAX_OPEN_FILES 10 #endif /* Define the file system memory allocation structure. */ struct fs_table { struct fs_file file; u8_t inuse; }; /* Allocate file system memory */ struct fs_table fs_memory[LWIP_MAX_OPEN_FILES]; #if LWIP_HTTPD_CUSTOM_FILES int fs_open_custom(struct fs_file *file, const char *name); void fs_close_custom(struct fs_file *file); #endif /* LWIP_HTTPD_CUSTOM_FILES */ /*-----------------------------------------------------------------------------------*/ static struct fs_file * fs_malloc(void) { int i; for(i = 0; i < LWIP_MAX_OPEN_FILES; i++) { if(fs_memory[i].inuse == 0) { fs_memory[i].inuse = 1; return(&fs_memory[i].file); } } return(NULL); } /*-----------------------------------------------------------------------------------*/ static void fs_free(struct fs_file *file) { int i; for(i = 0; i < LWIP_MAX_OPEN_FILES; i++) { if(&fs_memory[i].file == file) { fs_memory[i].inuse = 0; break; } } return; } /*-----------------------------------------------------------------------------------*/ struct fs_file * fs_open(const char *name) { struct fs_file *file; const struct fsdata_file *f; file = fs_malloc(); if(file == NULL) { return NULL; } #if LWIP_HTTPD_CUSTOM_FILES if(fs_open_custom(file, name)) { file->is_custom_file = 1; return file; } file->is_custom_file = 0; #endif /* LWIP_HTTPD_CUSTOM_FILES */ for(f = FS_ROOT; f != NULL; f = f->next) { if (!strcmp(name, (char *)f->name)) { file->data = (const char *)f->data; file->len = f->len; file->index = f->len; file->pextension = NULL; file->http_header_included = f->http_header_included; #if HTTPD_PRECALCULATED_CHECKSUM file->chksum_count = f->chksum_count; file->chksum = f->chksum; #endif /* HTTPD_PRECALCULATED_CHECKSUM */ #if LWIP_HTTPD_FILE_STATE file->state = fs_state_init(file, name); #endif /* #if LWIP_HTTPD_FILE_STATE */ return file; } } fs_free(file); return NULL; } /*-----------------------------------------------------------------------------------*/ void fs_close(struct fs_file *file) { #if LWIP_HTTPD_CUSTOM_FILES if (file->is_custom_file) { fs_close_custom(file); } #endif /* LWIP_HTTPD_CUSTOM_FILES */ #if LWIP_HTTPD_FILE_STATE fs_state_free(file, file->state); #endif /* #if LWIP_HTTPD_FILE_STATE */ fs_free(file); } /*-----------------------------------------------------------------------------------*/ int fs_read(struct fs_file *file, char *buffer, int count) { int read; if(file->index == file->len) { return -1; } read = file->len - file->index; if(read > count) { read = count; } MEMCPY(buffer, (file->data + file->index), read); file->index += read; return(read); } /*-----------------------------------------------------------------------------------*/ int fs_bytes_left(struct fs_file *file) { return file->len - file->index; } Файл fsdata.c Код #include "fs.h" #include "lwip/def.h" #include "fsdata.h" #define file_NULL (struct fsdata_file *) NULL static const unsigned int dummy_align__index_html = 0; static const unsigned char data__index_html[] = { /* /index.html (12 chars) */ 0x2f,0x69,0x6e,0x64,0x65,0x78,0x2e,0x68,0x74,0x6d,0x6c,0x00, /* HTTP header */ /* "HTTP/1.0 200 OK " (17 bytes) */ 0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x30,0x20,0x32,0x30,0x30,0x20,0x4f,0x4b,0x0d, 0x0a, /* "Server: lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip) " (63 bytes) */ 0x53,0x65,0x72,0x76,0x65,0x72,0x3a,0x20,0x6c,0x77,0x49,0x50,0x2f,0x31,0x2e,0x33, 0x2e,0x31,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x61,0x76,0x61,0x6e, 0x6e,0x61,0x68,0x2e,0x6e,0x6f,0x6e,0x67,0x6e,0x75,0x2e,0x6f,0x72,0x67,0x2f,0x70, 0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6c,0x77,0x69,0x70,0x29,0x0d,0x0a, /* "Content-type: text/html " (27 bytes) */ 0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x3a,0x20,0x74,0x65, 0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x0d,0x0a,0x0d,0x0a, /* raw file data (569 bytes) */ 0x3c,0x21,0x44,0x4f,0x43,0x54,0x59,0x50,0x45,0x20,0x48,0x54,0x4d,0x4c,0x20,0x50, 0x55,0x42,0x4c,0x49,0x43,0x20,0x22,0x2d,0x2f,0x2f,0x57,0x33,0x43,0x2f,0x2f,0x44, 0x54,0x44,0x20,0x48,0x54,0x4d,0x4c,0x20,0x34,0x2e,0x30,0x31,0x20,0x54,0x72,0x61, 0x6e,0x73,0x69,0x74,0x69,0x6f,0x6e,0x61,0x6c,0x2f,0x2f,0x45,0x4e,0x22,0x3e,0x0d, 0x0a,0x3c,0x68,0x74,0x6d,0x6c,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x76,0x3d,0x22, 0x75,0x72,0x6e,0x3a,0x73,0x63,0x68,0x65,0x6d,0x61,0x73,0x2d,0x6d,0x69,0x63,0x72, 0x6f,0x73,0x6f,0x66,0x74,0x2d,0x63,0x6f,0x6d,0x3a,0x76,0x6d,0x6c,0x22,0x20,0x78, 0x6d,0x6c,0x6e,0x73,0x3a,0x6f,0x3d,0x22,0x75,0x72,0x6e,0x3a,0x73,0x63,0x68,0x65, 0x6d,0x61,0x73,0x2d,0x6d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x2d,0x63,0x6f, 0x6d,0x3a,0x6f,0x66,0x66,0x69,0x63,0x65,0x3a,0x6f,0x66,0x66,0x69,0x63,0x65,0x22, 0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x77,0x3d,0x22,0x75,0x72,0x6e,0x3a,0x73,0x63, 0x68,0x65,0x6d,0x61,0x73,0x2d,0x6d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x2d, 0x63,0x6f,0x6d,0x3a,0x6f,0x66,0x66,0x69,0x63,0x65,0x3a,0x77,0x6f,0x72,0x64,0x22, 0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77, 0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x54,0x52,0x2f,0x52,0x45,0x43, 0x2d,0x68,0x74,0x6d,0x6c,0x34,0x30,0x22,0x3e,0x3c,0x68,0x65,0x61,0x64,0x3e,0x0d, 0x0a,0x3c,0x6d,0x65,0x74,0x61,0x20,0x68,0x74,0x74,0x70,0x2d,0x65,0x71,0x75,0x69, 0x76,0x3d,0x22,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x54,0x79,0x70,0x65,0x22, 0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x22,0x74,0x65,0x78,0x74,0x2f,0x68, 0x74,0x6d,0x6c,0x3b,0x20,0x63,0x68,0x61,0x72,0x73,0x65,0x74,0x3d,0x69,0x73,0x6f, 0x2d,0x38,0x38,0x35,0x39,0x2d,0x31,0x22,0x3e,0x0d,0x0a,0x3c,0x6c,0x69,0x6e,0x6b, 0x20,0x72,0x65,0x6c,0x3d,0x22,0x46,0x69,0x6c,0x65,0x2d,0x4c,0x69,0x73,0x74,0x22, 0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x53,0x54,0x4d,0x33,0x32,0x46,0x34,0x78,0x37, 0x5f,0x66,0x69,0x6c,0x65,0x73,0x2f,0x66,0x69,0x6c,0x65,0x6c,0x69,0x73,0x74,0x2e, 0x78,0x6d,0x6c,0x22,0x3e,0x0d,0x0a,0x3c,0x6c,0x69,0x6e,0x6b,0x20,0x72,0x65,0x6c, 0x3d,0x22,0x45,0x64,0x69,0x74,0x2d,0x54,0x69,0x6d,0x65,0x2d,0x44,0x61,0x74,0x61, 0x22,0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x53,0x54,0x4d,0x33,0x32,0x46,0x34,0x78, 0x37,0x5f,0x66,0x69,0x6c,0x65,0x73,0x2f,0x65,0x64,0x69,0x74,0x64,0x61,0x74,0x61, 0x2e,0x6d,0x73,0x6f,0x22,0x3e,0x3c,0x74,0x69,0x74,0x6c,0x65,0x3e,0x53,0x54,0x4d, 0x33,0x32,0x46,0x34,0x78,0x37,0x3c,0x2f,0x74,0x69,0x74,0x6c,0x65,0x3e,0x3c,0x2f, 0x68,0x65,0x61,0x64,0x3e,0x0d,0x0a,0x3c,0x62,0x6f,0x64,0x79,0x20,0x73,0x74,0x79, 0x6c,0x65,0x3d,0x22,0x22,0x20,0x6c,0x61,0x6e,0x67,0x3d,0x22,0x45,0x4e,0x2d,0x55, 0x53,0x22,0x20,0x6c,0x69,0x6e,0x6b,0x3d,0x22,0x62,0x6c,0x75,0x65,0x22,0x20,0x76, 0x6c,0x69,0x6e,0x6b,0x3d,0x22,0x62,0x6c,0x75,0x65,0x22,0x3e,0x0d,0x0a,0x48,0x65, 0x6c,0x6c,0x6f,0x20,0x77,0x6f,0x72,0x6c,0x64,0x0d,0x0a,0x3c,0x2f,0x62,0x6f,0x64, 0x79,0x3e,0x3c,0x2f,0x68,0x74,0x6d,0x6c,0x3e,}; const struct fsdata_file file__index_html[] = { { file_NULL, data__index_html, data__index_html + 12, sizeof(data__index_html) - 12, 1, }}; #define FS_ROOT file__index_html #define FS_NUMFILES 1 Примечательно, что подобные операции в оригинальном проекте от ST стабильно работают. Подскажите, пожалуйста, что не так?
  2. STM32F4 ETHERNET + CAN

    Понял Вас. Большое Спасибо за помощь.
  3. STM32F4 ETHERNET + CAN

    Если вас не затруднит, не могли бы вы разъяснить начинающему, что такое CUBE, SPL или HAL? Я раньше опирался на примеры уже готовых программ, а они были написаны в подобной форме. Что я делаю не так, и где нужно почитать, чтобы делать правильно? Спасибо
  4. STM32F4 ETHERNET + CAN

    Здравствуйте! Проект: Управление отправкой и приёмом CAN сообщений через Ethernet с помощью браузера. Проблема: Не работает CAN, как на приём, так и на передачу сообщений. Судя по флагам, микроконтроллер проходит по всем строчкам инициализации CAN, заходит в функцию отправки сообщений, однако, ничего не отправляет. Коммутация рабочая. Подскажите, пожалуйста, как чинить? Инициализация: void CAN1_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; /* CAN GPIOs configuration **************************************************/ /* Enable GPIO clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); /* Connect CAN pins */ GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_CAN1); GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_CAN1); /* Configure CAN RX and TX pins */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOB, &GPIO_InitStructure); /* CAN configuration ********************************************************/ /* Enable CAN clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE); /* CAN register init */ CAN_DeInit(CAN1); CAN_StructInit(&CAN_InitStructure); /* CAN cell init */ CAN_InitStructure.CAN_TTCM = DISABLE; CAN_InitStructure.CAN_ABOM = DISABLE; CAN_InitStructure.CAN_AWUM = DISABLE; CAN_InitStructure.CAN_NART = DISABLE; CAN_InitStructure.CAN_RFLM = DISABLE; CAN_InitStructure.CAN_TXFP = DISABLE; CAN_InitStructure.CAN_Mode = CAN_Mode_Normal; CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; /* CAN Baudrate = 1MBps (CAN clocked at 30 MHz) */ CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq; CAN_InitStructure.CAN_BS2 = CAN_BS2_8tq; CAN_InitStructure.CAN_Prescaler = 2; CAN_Init(CAN1, &CAN_InitStructure); /* CAN filter init */ CAN_FilterInitStructure.CAN_FilterNumber = 0; CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_Filter_FIFO0; CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask; CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit; CAN_FilterInitStructure.CAN_FilterActivation = ENABLE; CAN_FilterInitStructure.CAN_FilterIdHigh = 0; CAN_FilterInitStructure.CAN_FilterIdLow = 0; CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0; CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0; CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE); CAN_ITConfig(CAN1, CAN_IT_TME, ENABLE); CAN_FilterInit(&CAN_FilterInitStructure); } void NVIC_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = CAN1_TX_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } Функция отправки: void ASK_1(void) { CanTxMsg TxMessage; // if (CAN_GetITStatus (CAN1, CAN_IT_TME)) // { // CAN_ClearITPendingBit(CAN1,CAN_IT_TME); ASK1_DATA0='1'; TxMessage.StdId = 0x101; TxMessage.RTR = CAN_RTR_DATA; TxMessage.IDE = CAN_ID_STD; TxMessage.DLC = 1; TxMessage.Data[0] = ASK1_DATA0; //CAN1->TSR&CAN_TSR_TXOK0; CAN_Transmit(CAN1,&TxMessage); // } } Функция приёма: void CAN1_RX0_IRQHandler(void) { CanRxMsg RxMessage; if (CAN_GetITStatus (CAN1, CAN_IT_FMP0)) { CAN_ClearITPendingBit(CAN1,CAN_IT_FMP0); CAN_Receive(CAN1,CAN_FIFO0, &RxMessage); CAN_FIFORelease (CAN1,CAN_FIFO0); READ_DATA0=RxMessage.Data[0]; READ_DATA1=RxMessage.Data[1]; READ_DATA2=RxMessage.Data[2]; READ_DATA3=RxMessage.Data[3]; Can1Flag = ENABLE; } }
  5. STM32F091 CAN filters init

    На STM32F4 у меня пропускает сообщения от устройств с айдишниками от 100 до 199. CAN_FilterInitStructure.CAN_FilterNumber = 0; CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_Filter_FIFO0; CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask; CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit; CAN_FilterInitStructure.CAN_FilterActivation = ENABLE; CAN_FilterInitStructure.CAN_FilterIdHigh = 0x100 << 5; CAN_FilterInitStructure.CAN_FilterIdLow = 0x199 << 5; CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x700 << 5; CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0;
  6. Хорошо. Я вас понял. Главный вопрос в инициализации у меня относительно строк CAN_FilterIdHigh, CAN_FilterIdLow, CAN_FilterMaskIdHigh, CAN_FilterMaskIdLow. Я не очень понимаю, что конкретно в них писать. В них нужно писать диапазон Id? Если да, то зачем нужны какие-то скобки? CAN_FilterInitStructure.CAN_FilterNumber = 0; CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask; CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit; CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000; CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000; CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000; CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000; CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0; CAN_FilterInitStructure.CAN_FilterActivation = ENABLE; CAN_FilterInit(&CAN_FilterInitStructure);
  7. Добрый день! У меня CAN-шиной соединены 4 устройства STM32F4. Каждое из них подсоединено к компьютеру по USART для возможности вывода на экран входящих и исходящих сообщений. При отправке данных от одного устройства к конкретному другому, сообщение всё равно отображают все 4 устройства. Объясните, пожалуйста, каким образом правильно настроить адресацию и фильтрацию сообщений на STM32F4.
×
×
  • Создать...