void lire_commande(LR_PARAM *input_params, char *fic_apprentissage, char *fic_params, int num_args, char **args) { long int i; input_params->T=5000; input_params->eta=0.1; for(i=1; (i<num_args) && (args[i][0] == '-'); i++){ printf("%s\n",args[i]); switch((args[i])[1]){ case 't': i++; sscanf(args[i],"%ld",&input_params->T); break; case 'a': i++; sscanf(args[i],"%lf",&input_params->eta); break; case '?': i++; aide();exit(0); break; default : printf("Unknown option %s\n",args[i]);Standby();aide();exit(0); } } if((i+1)>=num_args){ printf("\n ---------------------------- \n Insuffisant number of parameters\n ----------------------------\n\n"); Standby(); aide(); exit(0); } printf("%s %s\n",args[i],args[i+1]); strcpy(fic_apprentissage, args[i]); strcpy(fic_params, args[i+1]); }
void i2c_t::Init( I2C_TypeDef *pi2c, GPIO_TypeDef *PGpio, uint16_t SclPin, uint16_t SdaPin, uint32_t BitrateHz, const stm32_dma_stream_t *APDmaTx, const stm32_dma_stream_t *APDmaRx ) { ii2c = pi2c; IPGpio = PGpio; ISclPin = SclPin; ISdaPin = SdaPin; IBitrateHz = BitrateHz; Standby(); Resume(); // ==== DMA ==== // Here only unchanged parameters of the DMA are configured. DmaChnl = 3; // I2C3 if (ii2c == I2C1) DmaChnl = 1; else if (ii2c == I2C2) DmaChnl = 7; // Setup Dma TX PDmaTx = APDmaTx; dmaStreamAllocate(PDmaTx, IRQ_PRIO_MEDIUM, i2cDmaIrqHandler, this); dmaStreamSetPeripheral(PDmaTx, &ii2c->DR); // Setup Dma RX PDmaRx = APDmaRx; dmaStreamAllocate(PDmaRx, IRQ_PRIO_MEDIUM, i2cDmaIrqHandler, this); //dmaStreamAllocate(PDmaRx, 1, i2cDmaRXIrqHandler, NULL); dmaStreamSetPeripheral(PDmaRx, &ii2c->DR); }
void IgcLogger::slotCloseLogFile() { if( GeneralConfig::instance()->getLoggerAutostartMode() ) { // Correct landing time by subtraction of stand time on earth. QDateTime lt = QDateTime::currentDateTime().addSecs( -TOAL ); emit landingTime( lt ); Standby(); } }
uint8_t PillMgr_t::Write(uint8_t MemAddr, void *Ptr, uint32_t Length) { uint8_t *p8 = (uint8_t*)Ptr; Resume(); // Write page by page while(Length) { uint8_t ToWriteCnt = (Length > PILL_PAGE_SZ)? PILL_PAGE_SZ : Length; // Try to write uint32_t Retries = 0; while(true) { // Uart.Printf("Wr: try %u\r", Retries); if(i2c->WriteWrite(PILL_I2C_ADDR, &MemAddr, 1, p8, ToWriteCnt) == OK) { Length -= ToWriteCnt; p8 += ToWriteCnt; MemAddr += ToWriteCnt; break; // get out of trying } else { Retries++; if(Retries > 4) { Uart.Printf("Timeout1\r"); Standby(); return TIMEOUT; } chThdSleepMilliseconds(4); // Allow memory to complete writing } } // while trying } // Wait completion uint32_t Retries = 0; do { // Uart.Printf("Wait: try %u\r", Retries); chThdSleepMilliseconds(1); Retries++; if(Retries > 5) { // Uart.Printf("Timeout2\r"); Standby(); return TIMEOUT; } } while(i2c->CheckAddress(PILL_I2C_ADDR) != OK); Standby(); return OK; }
void i2c_t::Init( I2C_TypeDef *pi2c, GPIO_TypeDef *PGpio, uint16_t SclPin, uint16_t SdaPin, uint32_t BitrateHz, const stm32_dma_stream_t *APDmaTx, const stm32_dma_stream_t *APDmaRx ) { ii2c = pi2c; IPGpio = PGpio; ISclPin = SclPin; ISdaPin = SdaPin; IBitrateHz = BitrateHz; Standby(); Resume(); // ==== DMA ==== // Here only unchanged parameters of the DMA are configured. uint16_t DmaChnl = 3; // I2C3 if (ii2c == I2C1) DmaChnl = 1; else if (ii2c == I2C2) DmaChnl = 7; // Setup Dma TX PDmaTx = APDmaTx; dmaStreamAllocate(PDmaTx, IRQ_PRIO_MEDIUM, i2cDmaIrqHandler, this); dmaStreamSetPeripheral(PDmaTx, &ii2c->DR); dmaStreamSetMode (PDmaTx, STM32_DMA_CR_CHSEL(DmaChnl) | DMA_PRIORITY_LOW | STM32_DMA_CR_MSIZE_BYTE | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MINC | // Memory pointer increase STM32_DMA_CR_DIR_M2P | // Direction is memory to peripheral STM32_DMA_CR_TCIE // Enable Transmission Complete IRQ ); // Setup Dma RX PDmaRx = APDmaRx; dmaStreamAllocate(PDmaRx, IRQ_PRIO_MEDIUM, i2cDmaIrqHandler, this); //dmaStreamAllocate(PDmaRx, 1, i2cDmaRXIrqHandler, NULL); dmaStreamSetPeripheral(PDmaRx, &ii2c->DR); dmaStreamSetMode (PDmaRx, STM32_DMA_CR_CHSEL(DmaChnl) | DMA_PRIORITY_LOW | STM32_DMA_CR_MSIZE_BYTE | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MINC | // Memory pointer increase STM32_DMA_CR_DIR_P2M // Direction is peripheral to memory | STM32_DMA_CR_TCIE // Enable Transmission Complete IRQ ); }
cVideo::~cVideo(void) { playstate = VIDEO_STOPPED; for (int i = 0; i < 2; i++) { if (blank_data[i]) free(blank_data[i]); blank_data[i] = NULL; } /* disable DACs and SCART voltage */ Standby(true); if (fd >= 0) close(fd); }
zx_status_t Tas5760::Init() { Standby(); WriteReg(kRegDigitalControl, 0x05); // no HPF, no boost, Single Speed, Stereo Left Justified. WriteReg(kRegVolumeControlCnf, 0x80); // Fade enabled. WriteReg(kRegAnalogControl, 0x51); // PWM rate 16 x lrclk. WriteReg(kRegDigitalClipper2, 0xFF); // Disabled. WriteReg(kRegDigitalClipper1, 0xFC); // Disabled. ExitStandby(); uint8_t val = 0; ReadReg(kRegFaultCfgErrorStatus, &val); if (val != 0x00) { return ZX_ERR_INTERNAL; } return ZX_OK; }
void i2c_t::Init() { Standby(); Resume(); // ==== DMA ==== // Here only unchanged parameters of the DMA are configured. #ifdef STM32F2XX if (ii2c == I2C1) DmaChnl = 1; else if (ii2c == I2C2) DmaChnl = 7; else DmaChnl = 3; // I2C3 #endif dmaStreamAllocate(PDmaTx, IRQ_PRIO_MEDIUM, i2cDmaIrqHandler, this); dmaStreamSetPeripheral(PDmaTx, &ii2c->DR); dmaStreamAllocate(PDmaRx, IRQ_PRIO_MEDIUM, i2cDmaIrqHandler, this); dmaStreamSetPeripheral(PDmaRx, &ii2c->DR); }
void PillMgr_t::Check() { // Uart.Printf("PillChk\r"); Resume(); if(IsConnectedNow) { // Check if disconnected if(i2c->CheckAddress(PILL_I2C_ADDR) == OK) State = pillNoChange; else { IsConnectedNow = false; State = pillJustDisconnected; } } else { // Was not connected uint8_t Rslt = Read(PILL_DATA_ADDR, &Pill, PILL_SZ); if(Rslt == OK) { IsConnectedNow = true; State = pillJustConnected; } else State = pillNoChange; } Standby(); }
void i2c_t::Init(I2C_TypeDef *pi2c, uint32_t BitrateHz) { ii2c = pi2c; IBitrateHz = BitrateHz; if(ii2c == I2C1) { IPGpio = GPIOB; ISclPin = 6; ISdaPin = 7; PDmaTx = STM32_DMA1_STREAM6; PDmaRx = STM32_DMA1_STREAM7; } Standby(); Resume(); // ==== DMA ==== // Here only unchanged parameters of the DMA are configured. // Setup Dma TX dmaStreamAllocate(PDmaTx, IRQ_PRIO_MEDIUM, i2cDmaIrqHandler, this); dmaStreamSetPeripheral(PDmaTx, &ii2c->DR); dmaStreamSetMode (PDmaTx, DMA_PRIORITY_LOW | STM32_DMA_CR_MSIZE_BYTE | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MINC | // Memory pointer increase STM32_DMA_CR_DIR_M2P | // Direction is memory to peripheral STM32_DMA_CR_TCIE // Enable Transmission Complete IRQ ); // Setup Dma RX dmaStreamAllocate(PDmaRx, IRQ_PRIO_MEDIUM, i2cDmaIrqHandler, this); dmaStreamSetPeripheral(PDmaRx, &ii2c->DR); dmaStreamSetMode (PDmaRx, DMA_PRIORITY_LOW | STM32_DMA_CR_MSIZE_BYTE | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MINC | // Memory pointer increase STM32_DMA_CR_DIR_P2M // Direction is peripheral to memory | STM32_DMA_CR_TCIE // Enable Transmission Complete IRQ ); }
void i2c_t::Reset() { Standby(); Resume(); }
uint8_t PillMgr_t::Read(uint8_t MemAddr, void *Ptr, uint32_t Length) { Resume(); uint8_t Rslt = i2c->WriteRead(PILL_I2C_ADDR, &MemAddr, 1, (uint8_t*)Ptr, Length); Standby(); return Rslt; }
bool Standby() { uint8_t dummy; return Standby(dummy); }