Exemplo n.º 1
0
/**********************************************************************//**
 * @brief  Global API call to record audio on the mike. 
 * 
 * - Initializes the record using setupRecord()
 * - Erases the memory reserved for audio recording
 * - Records until the memory is full using record()
 * - Shuts down the record using shutdownRecord()
 * 
 * @param  mode The mode of audio record 
 * 
 * - AUDIO_TEST_MODE ...for production test
 * - AUDIO_DEMO_MODE ...called for user sample code
 * 
 * @return none
 *************************************************************************/
void audioRecord(unsigned char mode)
{
  unsigned char i;
    
  setupRecord(); 

  halLcdPrintLine("   Erasing  ", 6, INVERT_TEXT | OVERWRITE_TEXT);  
  halLcdPrintLineCol("----", 8, 12,  OVERWRITE_TEXT);
  
  // Not used in User Experience sample code 
  if (mode == AUDIO_TEST_MODE)
  {
    flashErase(MemstartTest, Memend);
    __data16_write_addr((unsigned short)&DMA0DA, MemstartTest);      
    DMA0SZ = (long) (Memend - MemstartTest);
    
    record();
    
    if (DMA0SZ != ( long) (Memend - MemstartTest))
      lastAudioByte = Memend - DMA0SZ;
    else
      lastAudioByte = Memend;
  }
  // Always used in User Experience sample code 
  else
  {
    flashEraseBank(AUDIO_MEM_START[0]);
    flashEraseBank(AUDIO_MEM_START[1]);
    flashEraseBank(AUDIO_MEM_START[2]);
    flashErase(AUDIO_MEM_START[3], AUDIO_MEM_START[4]);    
    
    for (i=0;i<3;i++)
    {  
      __data16_write_addr((unsigned short)&DMA0DA, AUDIO_MEM_START[i]);               
      DMA0SZ = AUDIO_MEM_START[i+1] - AUDIO_MEM_START[i] - 1;
      
      record();
      
      if (DMA0SZ != AUDIO_MEM_START[i+1] - AUDIO_MEM_START[i] - 1)
      {
        lastAudioByte = AUDIO_MEM_START[i+1] - DMA0SZ;
        break;
      }
      else lastAudioByte = AUDIO_MEM_START[i+1]-1;      
    }
  }
  
  shutdownRecord();
}
Exemplo n.º 2
0
STATUS
flashFsIoctl(BLK_DEV *pDev, int funcCode, int arg)
{
    int			sectorAfterBoot;

    if (flashFsVerbose > 1)
	printf("flashFsIoctl(): called\n");

    switch (funcCode) {
    case FIODISKFORMAT:
	/* Clear flashDrvLib's cached sector */
	if (flashDrvLibInit() == ERROR) {
	    printf("flashFsInit(): flashDrvLibInit() failed\n");
	    return (ERROR);
	}

	/* From beginning of flash to beginning of Boot Area */
	if (flashEraseBank(0, FLASH_BOOT_START_SECTOR) == ERROR) {
	    return (ERROR);
	}

	sectorAfterBoot = FLASH_BOOT_START_SECTOR + FLASH_BOOT_SIZE_SECTORS;

	/* From end of Boot Area to end of flash */
	if (flashEraseBank(sectorAfterBoot,
			   FLASH_SIZE_SECTORS - sectorAfterBoot) == ERROR) {
	    return (ERROR);
	}
	break;

    case FLASH_FS_SYNC:
	flashSyncFilesystem();
	break;

    default:
	errnoSet(S_ioLib_UNKNOWN_REQUEST);
	return (ERROR);
	break;
    }

    return (OK);
}
Exemplo n.º 3
0
Arquivo: hal.c Projeto: ariavie/bcm
static int gto_upgrade_image(char *fname, unsigned int flags, 
                 int (*f_loader)(char *fname, char *fbuf, 
                                 int bufSize, int *entry_pt))
{
    char		*buf = 0;
    int			rv = -1;
    int			i = 0;
    int			entry;

    /* Re-probe in case jumper moved */
    if (flashDrvLibInit() == ERROR) {
        printf("flashBoot: Boot flash not found (jumpered right?)\n");
        goto done;
    }

    if ((buf = malloc(FLASH_BOOT_SIZE)) == 0) {
	printf("flashBoot: out of memory\n");
	goto done;
    }

    if (f_loader(fname, buf, FLASH_BOOT_SIZE, &entry) < 0) {
	printf("flashBoot: Failed to read image.\n");
	goto done;
    }

    printf("%d\nErasing boot area ...", i);

    for (i = FLASH_BOOT_START_SECTOR;
         i < FLASH_BOOT_START_SECTOR + FLASH_BOOT_SIZE_SECTORS; i++) {
        printf("FLASH_BOOT_START = 0x%08x\n", FLASH_BOOT_START);
        printf("FLASH_SECTOR_SIZE = %d\n", FLASH_SECTOR_SIZE);
        printf("FLASH_BOOT_START_SECTOR = %d\n", FLASH_BOOT_START_SECTOR);
        printf("FLASH_BOOT_SIZE_SECTORS = %d\n", FLASH_BOOT_SIZE_SECTORS);
    

        if (flashEraseBank(i, 1) != OK) {
	    printf("\nflashBoot: failed erasing -- PROM DESTROYED\n");
            goto done;
        }

        printf(".");
    }

    printf("done\nWriting boot data ...");

    if (flashBlkWrite(FLASH_BOOT_START_SECTOR, buf,
		      0, FLASH_BOOT_SIZE) != OK) {
        printf("\nflashBoot: failed writing -- PROM DESTROYED\n");
        goto done;
    }

    printf("\nDone\n");

    rv = 0;

 done:

    if (buf) {
	free(buf);
    }

    return rv;
}
Exemplo n.º 4
0
int
flashDiagnostic(void)
{
    unsigned int   *flashSectorBuff;
    int             sectorNum, i;

    /*
     * Probe flash; allocate flashLoadedSector Buffer
     */

    flashDrvLibInit();        /* Probe; clear loaded sector */

    flashSectorBuff = (unsigned int *) flashLoadedSectors[0].buffer;

    if (flashVerbose)
        printf("flashDiagnostic(): Executing. Erasing %d Sectors\n",
                flashSectorCount);

    if (flashEraseBank(0, flashSectorCount) == ERROR) {
    if (flashVerbose)
        printf("flashDiagnostic(): flashEraseBank() #1 failed\n");

    return (ERROR);
    }

    /* Write unique counting pattern to each sector. */
    for (sectorNum = 0; sectorNum < flashSectorCount; sectorNum++) {
    if (flashVerbose)
        printf("flashDiagnostic(): writing sector %d\n", sectorNum);

    for (i = 0; i < FLASH_SECTOR_SIZE / sizeof (unsigned int); i++)
        flashSectorBuff[i] = (i + sectorNum);

    if (flashDrvFuncs->flashWrite(sectorNum, (char *)flashSectorBuff,
               0, FLASH_SECTOR_SIZE) == ERROR) {
        if (flashVerbose)
        printf("flashDiagnostic(): flashWrite() failed on %d\n",
               sectorNum);

        return (ERROR);
    }
    }

    /* Verify each sector. */
    for (sectorNum = 0; sectorNum < flashSectorCount; sectorNum++) {
    if (flashVerbose)
        printf("flashDiagnostic(): verifying sector %d\n", sectorNum);

    if (flashDrvFuncs->flashRead(sectorNum, (char *)flashSectorBuff,
              0, FLASH_SECTOR_SIZE) == ERROR) {
        if (flashVerbose)
        printf("flashDiagnostic(): flashRead() failed on %d\n",
               sectorNum);

        return (ERROR);
    }

    for (i = 0; i < FLASH_SECTOR_SIZE / sizeof (unsigned int); i++) {
        if (flashSectorBuff[i] != (i + sectorNum)) {
        if (flashVerbose) {
            printf("flashDiagnostic(): verification failed\n");
            printf("flashDiagnostic(): sector %d, offset 0x%x\n",
               sectorNum, (i * sizeof(unsigned int)));
            printf("flashDiagnostic(): expected 0x%x, got 0x%x\n",
               (i + sectorNum), (int)flashSectorBuff[i]);
        }

        return (ERROR);
        }
    }
    }

    if (flashEraseBank(0, flashSectorCount) == ERROR) {
    if (flashVerbose)
        printf("flashDiagnostic(): flashEraseBank() #2 failed\n");

        return (ERROR);
    }

    if (flashVerbose)
        printf("flashDiagnostic(): Completed without error\n");

    return (OK);
}
Exemplo n.º 5
0
Arquivo: hal.c Projeto: ariavie/bcm
static int jag_upgrade_image(char *fname, unsigned int flags, 
                 int (*f_loader)(char *fname, char *fbuf, 
                                 int bufSize, int *entry_pt))
{
    char		*buf = 0;
    int			rv = -1;
    int			i = 0;
    int			entry;
    int                 bootImgSize = 512 * 1024;
#if !defined(NSSIOLE)
    char		tmpc;
#endif /* !NSSIOLE */

    if (flashDrvLibInit() == ERROR) {
        printf("flashBoot: Boot flash not found (jumpered right?)\n");
        goto done;
    }

    if ((buf = malloc(bootImgSize)) == 0) {
	printf("flashBoot: out of memory\n");
	goto done;
    }

    if (f_loader(fname, buf, bootImgSize, &entry) < 0) {
	printf("flashBoot: Failed to read image.\n");
	goto done;
    }

#if !defined(NSSIOLE)
    for(i = 0; i < bootImgSize; i += 4) {
        tmpc = buf[i];
        buf[i] = buf[i + 3];
        buf[i + 3] = tmpc;

        tmpc = buf[i + 1];
        buf[i + 1] = buf[i + 2];
        buf[i + 2] = tmpc;
    }
#endif

    printf("%d\nErasing boot area ...", i);

    for (i = FLASH_BOOT_START_SECTOR;
         i < FLASH_BOOT_START_SECTOR + FLASH_BOOT_SIZE_SECTORS; i++) {

        if (flashEraseBank(i, 1) != OK) {
	    printf("\nflashBoot: failed erasing -- PROM DESTROYED\n");
            goto done;
        }

        printf(".");
    }

    printf("done\nWriting boot data ...");

    if (flashBlkWrite(FLASH_BOOT_START_SECTOR, buf,
		      0, bootImgSize) != OK) {
        printf("\nflashBoot: failed writing -- PROM DESTROYED\n");
        goto done;
    }

    printf("\nDone\n");

    rv = 0;

 done:

    if (buf) {
	free(buf);
    }

    return rv;
}