コード例 #1
0
ファイル: bias.c プロジェクト: SuperQubit/pr1242a
void BIAS_Clk(void){
	if (DAC_GetDataOutputValue(DAC_Channel_1) ^ BIAS_DAC_Value)
		{
			 BIAS_SetValue(BIAS_DAC_Value);
			 BIAS_DAC_Value = DAC_GetDataOutputValue(DAC_Channel_1);
		}		
}
コード例 #2
0
ファイル: analogout_api.c プロジェクト: allankliu/mbed
static inline int dac_read(dac_t *obj) {
    if (obj->pin == PA_4) {
        return (int)DAC_GetDataOutputValue(DAC_Channel_1);
    }
    if (obj->pin == PA_5) {
        return (int)DAC_GetDataOutputValue(DAC_Channel_2);
    }
    return 0;
}
コード例 #3
0
ファイル: bias.c プロジェクト: SuperQubit/pr1242a
void BIAS_SetValue(uint16_t val_dac){
		if (val_dac < 4096) DAC_SetChannel1Data(DAC_Align_12b_R, val_dac);
		else DAC_SetChannel1Data(DAC_Align_12b_R, 4095);
		
		DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);		 
		BIAS_DAC_Value = DAC_GetDataOutputValue(DAC_Channel_1);	
}
コード例 #4
0
int GetAnalogOutput(int dacNumber)
{
    assert_param(IS_DAC_ID_VALID(dacNumber));
    
    uint16_t dacValue;
    
    switch(dacNumber)
    {
    case DAC_1:
        dacValue = DAC_GetDataOutputValue(DAC_Channel_1);
        break;
    case DAC_2:
        dacValue = DAC_GetDataOutputValue(DAC_Channel_2);
        break;
    }
    
    return (int)dacValue;
}
コード例 #5
0
ファイル: bias.c プロジェクト: SuperQubit/pr1242a
void BIAS_Config(void){
	DAC_InitTypeDef DAC_InitStructure;
	GPIO_InitTypeDef GPIO_InitStructure;
	DAC_DeInit();
  /* DAC Periph clock enable */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
	 /* DAC channel1 Configuration */
  DAC_InitStructure.DAC_Trigger = DAC_Trigger_Software;
  DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
  DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude =  DAC_TriangleAmplitude_1;
  DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
  DAC_Init(DAC_Channel_1, &DAC_InitStructure);
	/* Enable DAC Channel1: Once the DAC channel1 is enabled, PA.04 is 
     automatically connected to the DAC converter. */
  DAC_Cmd(DAC_Channel_1, ENABLE);
  /* Set DAC Channel1 DHR12L register */
  //DAC_SetChannel1Data(DAC_Align_12b_L, 0x7FF0);
  //DAC_SetChannel1Data(DAC_Align_12b_L, 0x9B20);
	//DAC_SetChannel1Data(DAC_Align_12b_R, 0x04D9);
	//BIAS_DAC_Value = DAC_GetDataOutputValue(DAC_Channel_1);
	DAC_SetChannel1Data(DAC_Align_12b_R, DAC_OUT_BOOT);
	//BIAS_DAC_Value = DAC_GetDataOutputValue(DAC_Channel_1);
	DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);
	BIAS_DAC_Value = DAC_GetDataOutputValue(DAC_Channel_1);
  /* Once the DAC channel is enabled, the corresponding GPIO pin is automatically 
     connected to the DAC converter. In order to avoid parasitic consumption, 
     the GPIO pin should be configured in analog */
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);	 
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_4;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
	 /* Used peripherals clock enable -------------------------------------------*/
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
	
	 /* configure PC9 as output push-pull  */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_Init(GPIOC, &GPIO_InitStructure);
	GPIO_SetBits(GPIOC, GPIO_Pin_9);	
}
コード例 #6
0
ファイル: analogout_api.c プロジェクト: allankliu/mbed
static inline int dac_read(dac_t *obj) {
    DAC_TypeDef *dac = (DAC_TypeDef *)(obj->dac);
    return (int)DAC_GetDataOutputValue(dac, DAC_Channel_1);
}