コード例 #1
0
ファイル: uart.cpp プロジェクト: stxy0509/GoldRoulette
void C_UART::Configure(int rate,void (*p)())
{
	if(!IsvalidBitRate(rate) || p == NULL || HaveConfigured) 
	{
		return;
	}
	BitRate = rate;
	UartConfig(Channel,BitRate);
	if(Channel == 0)
	{
		FullDuplex = true;
	}
	else 
	{
		FullDuplex = false;
		//485 CONTROL LINE,半双工需要一个
		//开关来控制数据的接收和发送
		gpio_set_port_output(45);
	}
	SetInterruptPriority(UartIntNumber[Channel],1);
	vgSetInterrupt(UartIntNumber[Channel],p);
	EnableReceData();
	//enable data receive interrupt
    *(UIE[Channel]) = 0x01; 
	vgEnableInterrupt(UartIntNumber[Channel],true); 
	HaveConfigured = true;
}
コード例 #2
0
ファイル: VGA.c プロジェクト: skeezix/zikzak
static void SetVGAHorizontalSync31kHzAtInterrupt(InterruptHandler *handler,int dier)
{
    WaitForLastLineIfVGAEnabled();

    TIM2->DIER=dier;
    TIM2->CCER=TIM_CCER_CC4E|TIM_CCER_CC4P; // Channel 4 enabled, reversed polarity (active low).

    // Enable HSync timer interrupt and set highest priority.
    InstallInterruptHandler(TIM2_IRQn,handler);
    EnableInterrupt(TIM2_IRQn);
    SetInterruptPriority(TIM2_IRQn,0);
}
コード例 #3
0
ファイル: VGA.c プロジェクト: skeezix/zikzak
static void SetVGAHorizontalSync31kHzActiveHighAtInterrupt(InterruptHandler *handler,int dier)
{
    WaitForLastLineIfVGAEnabled();

    TIM2->DIER=dier; // Enable update interrupt.
    TIM2->CCER=TIM_CCER_CC4E; // Channel 4 enabled, normal polarity (active high).

    // Enable HSync timer interrupt and set highest priority.
    InstallInterruptHandler(TIM2_IRQn,handler);
    EnableInterrupt(TIM2_IRQn);
    SetInterruptPriority(TIM2_IRQn,0);
}
コード例 #4
0
ファイル: VGA.c プロジェクト: darthrake/U23-Library
static void InitializePixelDMA(int pixelclock)
{
	// Configure timer 8 as the pixel clock.
	TIM8->CR1=TIM_CR1_ARPE;
	TIM8->DIER=TIM_DIER_UDE; // Enable update DMA request.
	TIM8->PSC=0; // Prescaler = 1
	TIM8->ARR=pixelclock-1; // TODO: Should this be -1?

	// DMA2 stream 1 channel 7 is triggered by timer 8.
	// Stop it and configure interrupts.
	DMA2_Stream1->CR&=~DMA_SxCR_EN;
	InstallInterruptHandler(DMA2_Stream1_IRQn,DMACompleteHandler);
	EnableInterrupt(DMA2_Stream1_IRQn);
	SetInterruptPriority(DMA2_Stream1_IRQn,0);
}
コード例 #5
0
ファイル: Audio.c プロジェクト: skeezix/zikzak
void PlayAudioWithCallback(AudioCallbackFunction *callback,void *context)
{
	StopAudioDMA();

	InstallInterruptHandler(DMA1_Stream7_IRQn,DMACompleteHandler);
	EnableInterrupt(DMA1_Stream7_IRQn);
	SetInterruptPriority(DMA1_Stream7_IRQn,4);

	SPI3->CR2|=SPI_CR2_TXDMAEN; // Enable I2S TX DMA request.

	CallbackFunction=callback;
	CallbackContext=context;
	BufferNumber=0;

	if(CallbackFunction) CallbackFunction(CallbackContext,BufferNumber);
}
コード例 #6
0
ファイル: VGA.c プロジェクト: skeezix/zikzak
static void InitializePixelDMA(int pixelclock,int pixelsperrow)
{
    // Configure timer 8 as the pixel clock.
    TIM8->CR1=TIM_CR1_ARPE;
    TIM8->DIER=TIM_DIER_UDE; // Enable update DMA request.
    TIM8->PSC=0; // Prescaler = 1.
    TIM8->ARR=pixelclock-1;
    TIM8->SMCR=(5*TIM_SMCR_SMS_0)|(1*TIM_SMCR_TS_0); // Only run TIM8 when TIM2 trigger-out is high.

    // DMA2 stream 1 channel 7 is triggered by timer 8.
    // Stop it and configure interrupts.
    DMA2_Stream1->CR&=~DMA_SxCR_EN;
    InstallInterruptHandler(DMA2_Stream1_IRQn,DMACompleteHandler);
    EnableInterrupt(DMA2_Stream1_IRQn);
    SetInterruptPriority(DMA2_Stream1_IRQn,0);

    VGAPixelsPerRow=pixelsperrow;
}
コード例 #7
0
ファイル: VGA.c プロジェクト: darthrake/U23-Library
void InitializeVGAHorizontalSync31kHz(InterruptHandler *handler)
{
	// Configure timer 9 as the HSYNC timer.
	TIM9->CR1=TIM_CR1_ARPE;
	TIM9->DIER=TIM_DIER_UIE|TIM_DIER_CC1IE|TIM_DIER_CC2IE; // Enable update, compare 1 and 2 interrupts.
	TIM9->CCMR1=0;
	TIM9->CCER=0;
	TIM9->PSC=0; // Prescaler = 1
	TIM9->ARR=5337; // 168 MHz / 31.4686 kHz = 5338.65504
	TIM9->CCR1=633; // 168 MHz * 3.77 microseconds = 633.36 - sync pulse end
	TIM9->CCR2=950; // 168 MHz * (3.77 + 1.89) microseconds = 950.88 - back porch end

	// Enable HSYNC timer interrupt and set highest priority.
	InstallInterruptHandler(TIM1_BRK_TIM9_IRQn,handler);
	EnableInterrupt(TIM1_BRK_TIM9_IRQn);
	SetInterruptPriority(TIM1_BRK_TIM9_IRQn,0);

	// Enable HSYNC timer.
	TIM9->CR1|=TIM_CR1_CEN;
}