Beispiel #1
0
/**
 * Main.
 */
int main(int argc, char *argv[])
{
    FLAC__bool ok = true;
	FLAC__StreamDecoder* decoder = 0;
	FLAC__StreamDecoderInitStatus init_status;

	// init system
	SystemInit();
	RCC_configure();
	GPIO_configure();

    //TODO
    // setup UART, LEDs, SDIO, I2S, etc

    // setup decoder
	if((decoder = FLAC__stream_decoder_new()) == NULL) {
		fprintf(stderr, "ERROR: allocating decoder\n");
		return 1;
	}

    // optional MD5 check. How much cycles does this cost?
	//FLAC__stream_decoder_set_md5_checking(decoder, true);

    // init decoder
    void* client_data = 0;  //TODO
	init_status = FLAC__stream_decoder_init_stream(decoder, 
        read_callback,
        seek_callback,
        tell_callback,
        length_callback,
        eof_callback,
        write_callback, 
        metadata_callback,
        error_callback,
        client_data);
	if (init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
		fprintf(stderr, "ERROR: initializing decoder: %s\n", FLAC__StreamDecoderInitStatusString[init_status]);
		ok = false;
	}

	if (ok) {
		ok = FLAC__stream_decoder_process_until_end_of_stream(decoder);
		fprintf(stderr, "decoding: %s\n", ok? "succeeded" : "FAILED");
		fprintf(stderr, "   state: %s\n", FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(decoder)]);
	}

    // loop forever, just handle IRQs
	while(1);
     
    // never called but usefull to know
    //FLAC__stream_decoder_delete(decoder);
    
	return 0;
}
Beispiel #2
0
/*
 * MAIN
 */
int main() {

	GPIO_configure();

	/* Setup SysTick Timer for 1 msec interrupts */
	SysTick_Config(SystemCoreClock / 1000);

    while(1)
    {
    	GPIO_SetBits(LEDS_GPIO_PORT, GPIO_Pin_6);
    	delay(1000);
    	GPIO_ResetBits(LEDS_GPIO_PORT, GPIO_Pin_6);
    	delay(1000);
    }
}
Beispiel #3
0
static int gpio_config_cb(const USB_Status_TypeDef status, uint32_t xferred, uint32_t remaining)
{
    (void)xferred;
    (void)remaining;

    struct usbthing_ctrl_s *ctrl = (struct usbthing_ctrl_s*)&cmd_buffer;

    uint8_t pin = ctrl->gpio_cmd.config.pin;
	bool output = (ctrl->gpio_cmd.config.mode == USBTHING_GPIO_MODE_INPUT) ? false : true;
	bool pull_enabled = (ctrl->gpio_cmd.config.pull != 0) ? true : false;
	bool pull_direction = (ctrl->gpio_cmd.config.pull != 0) ? true : false;

    GPIO_configure(pin, output, pull_enabled, pull_direction);

    return USB_STATUS_OK;
}