From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5086 invoked by alias); 18 Jun 2014 10:08:32 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 5073 invoked by uid 89); 18 Jun 2014 10:08:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f180.google.com Received: from mail-wi0-f180.google.com (HELO mail-wi0-f180.google.com) (209.85.212.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 18 Jun 2014 10:08:29 +0000 Received: by mail-wi0-f180.google.com with SMTP id hi2so814407wib.1 for ; Wed, 18 Jun 2014 03:08:26 -0700 (PDT) X-Received: by 10.194.161.168 with SMTP id xt8mr46749811wjb.35.1403086106314; Wed, 18 Jun 2014 03:08:26 -0700 (PDT) Received: from smtp.gmail.com ([217.153.153.214]) by mx.google.com with ESMTPSA id l5sm2928370wif.22.2014.06.18.03.08.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jun 2014 03:08:25 -0700 (PDT) From: Jerzy Dyrda To: Oleg Uzenkov Cc: ecos-discuss@ecos.sourceware.org Date: Wed, 18 Jun 2014 10:08:00 -0000 Message-ID: <20637159.RNL73EHQft@inteldesktop.site> User-Agent: KMail/4.10.5 (Linux/3.7.10-1.32-desktop; KDE/4.10.5; x86_64; ; ) In-Reply-To: <53A15E38.9000605@unicore.co.ua> References: <53A14B41.3080106@unicore.co.ua> <5278288.Y2HcdZz25x@inteldesktop.site> <53A15E38.9000605@unicore.co.ua> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes Subject: Re: [ECOS] STM32 Standard Peripheral Library in eCos X-SW-Source: 2014-06/txt/msg00017.txt.bz2 Hello Oleg, On Wednesday 18 of June 2014 12:39:04 Oleg Uzenkov wrote: [snip] > > IMHO STM32 Standard Peripheral Library doesn't fit to any driver > > oriented OS but > > due to fact that it exists some system just incorporate it as it i.e. > > agreed for its drawbacks. > Please, could you name some OS that incorporate it? E.g. FreeRTOS. > Does anyone know of any examples using MMC SPI driver in ecos to interface > SD card (any platform)? I would appreciate any links or sample code. #include #ifdef CYGPKG_DEVS_DISK_MMC #include #include #endif #include #include // Test macros #include // Assertion macros #include // Diagnostic output #include #include #include #include #include #include #include // CYGNUM_HAL_STACK_SIZE_TYPICAL #include #include #include #include CYGHWR_MEMORY_LAYOUT_H #ifdef CYGPKG_NET_LWIP #include #endif // CYGPKG_NET_LWIP #ifdef CYGPKG_DEVS_DISK_MMC #include #include #endif externC int hello_world(void); void do_version (void); #ifdef CYGPKG_DEVS_DISK_MMC #ifdef CYGPKG_DEVS_SPI_CORTEXM_STM32 #include CYG_DEVS_SPI_CORTEXM_STM32_DEVICE ( cyg_spi_mmc_dev0, 3, 0, false, 0, 0, 5000000, 1, 1, 1 ); #else #error "Needed SPI connection to MMC card" #endif void checkcwd( const char *cwd ) { static char cwdbuf[PATH_MAX]; char *ret; ret = getcwd( cwdbuf, sizeof(cwdbuf)); if( ret == NULL ) diag_printf("Error getcwd\n"); if( strcmp( cwdbuf, cwd ) != 0 ) { diag_printf( "cwdbuf %s cwd %s\n",cwdbuf, cwd ); diag_printf( "Current directory mismatch"); } } static void listdir( char *name, int statp, int numexpected, int *numgot ) { int err; DIR *dirp; int num=0; diag_printf(": reading directory %s\n",name); dirp = opendir( name ); if( dirp == NULL ) diag_printf("Can't opendir\n"); for(;;) { struct dirent *entry = readdir( dirp ); if( entry == NULL ) break; num++; diag_printf(": entry %14s",entry->d_name); #ifdef CYGPKG_FS_FAT_RET_DIRENT_DTYPE diag_printf(" d_type %2x", entry->d_type); #endif if( statp ) { char fullname[PATH_MAX]; struct stat sbuf; if( name[0] ) { strcpy(fullname, name ); if( !(name[0] == '/' && name[1] == 0 ) ) strcat(fullname, "/" ); } else fullname[0] = 0; strcat(fullname, entry->d_name ); err = stat( fullname, &sbuf ); if( err < 0 ) { if( errno == ENOSYS ) diag_printf(" "); else diag_printf( "stat=%d err=%x\n", stat, err ); } else { diag_printf(" [mode %08x ino %08x nlink %d size %ld]", sbuf.st_mode,sbuf.st_ino,sbuf.st_nlink,(long)sbuf.st_size); } #ifdef CYGPKG_FS_FAT_RET_DIRENT_DTYPE if ((entry->d_type & S_IFMT) != (sbuf.st_mode & S_IFMT)) diag_printf("File mode's don't match between dirent and stat"); #endif } diag_printf("\n"); } err = closedir( dirp ); if( err < 0 ) diag_printf( "stat=%d err=%x\n", stat, err ); if (numexpected >= 0 && num != numexpected) diag_printf("Wrong number of dir entries\n"); if ( numgot != NULL ) *numgot = num; } #endif int main(void) { #ifdef CYGPKG_DEVS_DISK_MMC int existingdirents=-1; diag_printf("Mounting MMC disk\n"); if (ENOERR != mount( "/dev/mmcdisk0/", "/disk", "fatfs" )) diag_printf("MMC disk not mounted\n"); if (ENOERR != chdir( "/disk" )) diag_printf("Changing directory to /disk failed\n"); checkcwd( "/disk" ); listdir( "/disk", true, -1, &existingdirents ); #endif Best regards, jerzy -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss