Exemplo n.º 1
0
int app_batt_alert_timer_handler(ke_msg_id_t const msgid,
                                        void const *param,
										ke_task_id_t const dest_id,
										ke_task_id_t const src_id)
{
		
	
		//Read LED GPIO state
    if(bat_lvl_alert_used)
    {		
#if 0
			if (bat_led_state)
			{
				if(GPIO_GetPinStatus(GPIO_ALERT_PWR_PORT,GPIO_ALERT_PWR_PIN)==false)
				{
					//正在充电
				}
				else
				{
					GPIO_SetActive( bat_led_port, bat_led_pin);  //V3.2版本后将黄灯逻辑电平反向
					bat_led_state = 0;
				}
				app_timer_set(APP_BATT_ALERT_TIMER, dest_id, 50);//20,电池电量低,报警灯闪烁速度,,delay延时
			}
			else
			{
				GPIO_SetInactive( bat_led_port, bat_led_pin);//V3.2版本后将黄灯逻辑电平反向
				bat_led_state = 1;
				app_timer_set(APP_BATT_ALERT_TIMER, dest_id, 50);//5,电池电量低,报警灯闪烁速度,delay延时
			}
#endif
    }
		
    return (KE_MSG_CONSUMED);
}
Exemplo n.º 2
0
/**
 ****************************************************************************************
 * @brief Read from 3-wire SPI
 * @param[in] registerIndex: Target address (A6..A0)
 *
 * @return  byte read
 ****************************************************************************************
 */
uint8_t read_from_3wire_SPI_register(uint8_t registerIndex, uint8_t is_last_transaction)
{
    static uint8_t i, dataRead;

    GPIO_SetInactive(cs.port, cs.pin);                              // pull CS low

    GPIO_SetPinFunction( sdio.port, sdio.pin, OUTPUT, PID_SPI_DO);  // configure SDIO as output

    SetWord16(SPI_RX_TX_REG0, (uint16_t)(registerIndex) );          // MSB set to HIGH - A6..A0 Address of register to write to
    do {
    } while (GetBits16(SPI_CTRL_REG,SPI_INT_BIT)==0);               // polling to wait for spi transmission

    SetWord16(SPI_CLEAR_INT_REG, 0);                                //Clear SPI_CTRL_REG[SPI_INT_BIT] interrupt

    GPIO_SetPinFunction( sdio.port, sdio.pin, INPUT, PID_SPI_DI);   // configure SDIO as input

    for (i=0; i<TsradCounter; i++);                                 // {DEV.NOTE#: For Mouse sensor Delay > Tsrad = 4us <-- suitable counter is 6}

    SetWord16(SPI_RX_TX_REG0, (uint16_t)0x00 );                     // dummy write data - read data
    do {
    } while (GetBits16(SPI_CTRL_REG,SPI_INT_BIT)==0);               // polling to wait for spi transmission

    SetWord16(SPI_CLEAR_INT_REG, 0);                                //Clear SPI_CTRL_REG[SPI_INT_BIT] interrupt

    dataRead = GetWord16(SPI_RX_TX_REG0);                           // read received byte

    SetWord16(SPI_CLEAR_INT_REG, 0x01);                             // clear pending flag

    if(is_last_transaction)
        GPIO_SetActive(cs.port, cs.pin);                              // set CS high

    return dataRead;
}
Exemplo n.º 3
0
void uart_write_ext_wkup_func(uint8_t *bufptr, uint32_t size, void (*callback) (uint8_t))
{
    // Sanity check
    ASSERT_ERR(bufptr != NULL);
    ASSERT_ERR(size != 0);
    ASSERT_ERR(uart_env.tx.bufptr == NULL);
	
		GPIO_SetActive (EXT_WAKEUP_PORT, EXT_WAKEUP_PIN);
			
    // Prepare TX parameters
    uart_env.tx.size = size;
    uart_env.tx.bufptr = bufptr;
		uart_env.tx.callback = callback;

    /* start data transaction
     * first isr execution is done without interrupt generation to reduce
     * interrupt load
     */
    uart_thr_empty_isr();
    if (uart_env.tx.bufptr != NULL)
    {
			uart_thr_empty_setf(1);
    }
		GPIO_SetInactive (EXT_WAKEUP_PORT, EXT_WAKEUP_PIN);
}
Exemplo n.º 4
0
int app_batt_alert_timer_handler(ke_msg_id_t const msgid,
                                        void const *param,
										ke_task_id_t const dest_id,
										ke_task_id_t const src_id)
{
		
	
		//Read LED GPIO state
    if(bat_lvl_alert_used)
    {		
		if (bat_led_state)
		{
            GPIO_SetInactive( bat_led_port, bat_led_pin);            	

			bat_led_state = 0;
			app_timer_set(APP_BATT_ALERT_TIMER, dest_id, 20);
#ifdef CUSTOM_BATTERY_LEVEL_MEASUREMENTS___BOOST_MODE_CONFIGURATION
            if (app_get_sleep_mode())
                app_force_active_mode();    // prevent sleep only if enabled
#endif //CUSTOM_BATTERY_LEVEL_MEASUREMENTS___BOOST_MODE_CONFIGURATION
		}
		else
		{
            GPIO_SetActive( bat_led_port, bat_led_pin);

			bat_led_state = 1;
			app_timer_set(APP_BATT_ALERT_TIMER, dest_id, 5);
#ifdef CUSTOM_BATTERY_LEVEL_MEASUREMENTS___BOOST_MODE_CONFIGURATION
            app_restore_sleep_mode(); 
#endif //CUSTOM_BATTERY_LEVEL_MEASUREMENTS___BOOST_MODE_CONFIGURATION
		}
    }
		
    return (KE_MSG_CONSUMED);
}
/**
 ****************************************************************************************
 * @brief Sets the Red LED to blink
 *
 * @param   None    
 *
 * @return  void
 ****************************************************************************************
 */
void red_led_blink()
{
    if (LED_STATE_OFF) {
        GPIO_SetInactive(KBD_RED_LED_PORT,      KBD_RED_LED_PIN);       // red: low - on
    } else {
        GPIO_SetActive  (KBD_RED_LED_PORT,      KBD_RED_LED_PIN);       // red: high - on
    }
}
/**
 ****************************************************************************************
 * @brief Sets the Green LED to blink
 *
 * @param   None    
 *
 * @return  void
 ****************************************************************************************
 */
static void green_led_blink()
{
    if (LED_STATE_OFF) {
        GPIO_SetInactive(KBD_GREEN_LED_PORT,    KBD_GREEN_LED_PIN);     // green: low - on
    } else {
        GPIO_SetActive  (KBD_GREEN_LED_PORT,    KBD_GREEN_LED_PIN);     // green: high - on
    }
    green_led_st = BLINK_LED_IS_ON__TURN_OFF;
}
/**
 ****************************************************************************************
 * @brief Sets the Green LED to on
 *
 * @param   None    
 *
 * @return  void
 ****************************************************************************************
 */
static void green_led_on()
{
    if (LED_STATE_OFF) {
        GPIO_SetInactive(KBD_GREEN_LED_PORT,    KBD_GREEN_LED_PIN);     // green: low - on
    } else {
        GPIO_SetActive  (KBD_GREEN_LED_PORT,    KBD_GREEN_LED_PIN);     // green: high - on
    }
    green_led_st = LED_ON;
}
/**
 ****************************************************************************************
 * @brief Sets the Red LED to on
 *
 * @param   None    
 *
 * @return  void
 ****************************************************************************************
 */
static void red_led_on()
{
    if (LED_STATE_OFF) {
        GPIO_SetInactive(KBD_RED_LED_PORT,      KBD_RED_LED_PIN);       // red: low - on
    } else {
        GPIO_SetActive  (KBD_RED_LED_PORT,      KBD_RED_LED_PIN);       // red: high - on
    }
    red_led_st = LED_ON;
}
/**
 ****************************************************************************************
 * @brief Sets the Red LED to off
 *
 * @param   None    
 *
 * @return  void
 ****************************************************************************************
 */
static void red_led_off()
{
    high_priority_indications_active = false;
    if (LED_STATE_OFF) {
        GPIO_SetActive  (KBD_RED_LED_PORT,      KBD_RED_LED_PIN);       // red: high - off
    } else {
        GPIO_SetInactive(KBD_RED_LED_PORT,      KBD_RED_LED_PIN);       // red: low - off
    }
    red_led_st = LED_OFF;
}
Exemplo n.º 10
0
void app_proxr_port_reinit(GPIO_PORT port, GPIO_PIN pin)
{
    app_proxr_init(port, pin);

	if(alert_state.blink_toggle == 1){
        GPIO_SetActive( alert_state.port, alert_state.pin);
    }
	else{
        GPIO_SetInactive( alert_state.port, alert_state.pin);
	}
	
}
Exemplo n.º 11
0
void app_proxr_alert_stop(void)
{

	alert_state.lvl = PROXR_ALERT_NONE; //level;
	
	alert_state.blink_timeout = 0;
	alert_state.blink_toggle = 0;
	
    GPIO_SetInactive( alert_state.port, alert_state.pin);
	
    ke_timer_clear(APP_PXP_TIMER, TASK_APP);
}
Exemplo n.º 12
0
int app_proxr_timer_handler(ke_msg_id_t const msgid,
                                   void const *param,
                                   ke_task_id_t const dest_id,
                                   ke_task_id_t const src_id)
{

    if (alert_state.lvl != PROXR_ALERT_NONE)
    {
        if (alert_state.lvl == PROXR_ALERT_HIGH)
        {
            alert_state.blink_toggle =  1;
            app_timer_set(APP_PXP_TIMER, dest_id, alert_state.blink_timeout);
            GPIO_SetActive( alert_state.port, alert_state.pin);
            app_proxr_beep();
            GPIO_SetInactive(alert_state.port, alert_state.pin);
            alert_state.blink_toggle = 0;
        }
        else
        {
            if (alert_state.blink_toggle)
            {
               
                GPIO_SetInactive( alert_state.port, alert_state.pin);
                alert_state.blink_toggle = 0;
                app_timer_set(APP_PXP_TIMER, dest_id, alert_state.blink_timeout);
            }
            else
            {
                GPIO_SetActive( alert_state.port, alert_state.pin);
                alert_state.blink_toggle = 1;
                app_timer_set(APP_PXP_TIMER, dest_id, 2);
            }
        }
        
        app_timer_set(APP_PXP_TIMER, dest_id, alert_state.blink_timeout);
    }
		
    return (KE_MSG_CONSUMED);
}
Exemplo n.º 13
0
void app_sample128_start_leds(void)
{
		if(1 == leds_state.flag)
		{
        //GPIO_SetActive( leds_state.port_led3, leds_state.pin_led3);
			  GPIO_SetActive(leds_state.port_led4, leds_state.pin_led4);
			  //GPIO_SetInactive(leds_state.port_led4, leds_state.pin_led4);
			  GPIO_SetInactive( leds_state.port_led3, leds_state.pin_led3);
			  //GPIO_ConfigurePin( GPIO_LED3_PORT, GPIO_LED3_PIN, OUTPUT, PID_GPIO, true );
			  
    }
	  else if(0 == leds_state.flag)
		{
        GPIO_SetInactive(leds_state.port_led4, leds_state.pin_led4);
			  //GPIO_SetInactive( leds_state.port_led3, leds_state.pin_led3);
			  GPIO_SetActive( leds_state.port_led3, leds_state.pin_led3);
			  //GPIO_ConfigurePin( GPIO_LED3_PORT, GPIO_LED3_PIN, OUTPUT, PID_GPIO, false );
			  //GPIO_ConfigurePin( GPIO_LED3_PORT, GPIO_LED3_PIN, OUTPUT, PID_GPIO, false );
	      //GPIO_ConfigurePin( GPIO_LED4_PORT, GPIO_LED4_PIN, OUTPUT, PID_GPIO, false );
			
			  
	  }
}
Exemplo n.º 14
0
void app_batt_port_reinit(void)
{
    
    if (bat_lvl_alert_used)
    {
        if(bat_led_state == 1){
            GPIO_SetActive( bat_led_port, bat_led_pin);
        }
        else{
            GPIO_SetInactive( bat_led_port, bat_led_pin);
        }
    }


}
Exemplo n.º 15
0
/*
 * Name         : GPIO_ConfigurePin - Combined function to set the state
 *                                     and the type and mode of the GPIO pin 
 *
 * Scope        : PUBLIC
 *
 * Arguments    : port - GPIO port
 *                pin  - pin
 *                mode - pin mode (input, output...)
 *                function - pin usage (GPIO, UART, SPI...)
 *                high - set to TRUE to set the pin into high else low
 *
 * Description  : Sets the GPIO state and then its type and mode
 *
 * Returns      : void
 *
 */
void GPIO_ConfigurePin( GPIO_PORT port, GPIO_PIN pin, GPIO_PUPD mode, GPIO_FUNCTION function,
						 const bool high )
{
#if DEVELOPMENT__NO_OTP
    if ( !(GPIO_status & ( ((uint64_t)1 << pin) << (port * 16) )) )
                __asm("BKPT #0\n"); // this pin has not been previously reserved!        
#endif    
    
    if (high)
        GPIO_SetActive( port, pin );
    else
        GPIO_SetInactive( port, pin );
    
	GPIO_SetPinFunction( port, pin, mode, function );
}
Exemplo n.º 16
0
/**
 ****************************************************************************************
 * @brief Write to 3-wire SPI
 * @param[in] registerIndex: Target address (A6..A0)
 * @param[in] valueToWrite: Value to write
 *
 * @return  Number of read bytes
 ****************************************************************************************
 */
void write_to_3wire_SPI_register(uint8_t registerIndex, uint8_t valueToWrite)
{
    GPIO_SetInactive(cs.port, cs.pin);                              // pull CS low

    GPIO_SetPinFunction( sdio.port, sdio.pin, OUTPUT, PID_SPI_DO);  // configure SDIO as output

    SetWord16(SPI_RX_TX_REG0, (uint16_t)(registerIndex | 0x80) );   // MSB set to HIGH - A6..A0 Address of register to write to
    do {
    } while (GetBits16(SPI_CTRL_REG,SPI_INT_BIT)==0);               // polling to wait for spi transmission

    SetWord16(SPI_CLEAR_INT_REG, 0);                                //Clear SPI_CTRL_REG[SPI_INT_BIT] interrupt

    SetWord16(SPI_RX_TX_REG0, (uint16_t)valueToWrite );             // write data
    do {
    } while (GetBits16(SPI_CTRL_REG,SPI_INT_BIT)==0);               // polling to wait for spi transmission

    SetWord16(SPI_CLEAR_INT_REG, 0);                                // Clear SPI_CTRL_REG[SPI_INT_BIT] interrupt

    GPIO_SetActive(cs.port, cs.pin);                                // set CS high
}
/**
****************************************************************************************
* @brief Handles timer timeout
* @return If the message was consumed or not.
****************************************************************************************
*/
int sample128_timer_handler(ke_msg_id_t const msgid,
																 struct gapm_cmp_evt const *param,
																 ke_task_id_t const dest_id,
																 ke_task_id_t const src_id)
{
	//uint8_t Tmpi;
	//my_newer2_addChar Tmp_Buff;
	//ke_timer_set(APP_SAMPLE128_TIMER,TASK_APP,Sample_LED_Blink);
	//sample128_placeholder++;
	/*
	struct sample128_upd_char2_req *req = KE_MSG_ALLOC(
																	SAMPLE128_UPD_CHAR2_REQ,
																	TASK_SAMPLE128,
																	TASK_APP,
																	sample128_upd_char2_req
																	 );
	*/
	sample128_LED++;
	if(sample128_LED%2==0)
	{
		GPIO_SetActive(GPIO_PORT_1,GPIO_PIN_0);
	}
	else
	{
		GPIO_SetInactive(GPIO_PORT_1,GPIO_PIN_0);
	}
	uart2_write("Hello",strlen("Hello"),NULL);
	
	//user_uart_write(&sample128_LED,1,NULL);
	/*
	for(Tmpi=0;Tmpi<characristic2_length;Tmpi++)
	{
		Tmp_Buff[Tmpi]=(uint8_t)(sample128_LED+Tmpi);
	}
	memcpy(&req->val,Tmp_Buff,sizeof(my_newer2_addChar));
	req->val = sample128_placeholder;
	req->conhdl = app_env.conhdl;
	ke_msg_send(req);
	*/
	return (KE_MSG_CONSUMED);
}
Exemplo n.º 18
0
int app_proxr_timer_handler(ke_msg_id_t const msgid,
                                   void const *param,
                                   ke_task_id_t const dest_id,
                                   ke_task_id_t const src_id)
{
		 
		if (alert_state.blink_toggle)
		{
            GPIO_SetInactive( alert_state.port, alert_state.pin);
			alert_state.blink_toggle = 0;
		}
		else
		{
            GPIO_SetActive( alert_state.port, alert_state.pin);
			alert_state.blink_toggle = 1;
		}
		
		ke_timer_set(APP_PXP_TIMER, dest_id, alert_state.blink_timeout);
		
    return (KE_MSG_CONSUMED);
}
Exemplo n.º 19
0
void app_batt_alert_stop(void)
{	
	batt_alert_en = 0;

    if (bat_lvl_alert_used)
    {
#ifdef CUSTOM_BATTERY_LEVEL_MEASUREMENTS___LED_IS_ACTIVE_LOW        
        GPIO_SetActive( bat_led_port, bat_led_pin);    
#else
        GPIO_SetInactive( bat_led_port, bat_led_pin);        
#endif //CUSTOM_BATTERY_LEVEL_MEASUREMENTS___LED_IS_ACTIVE_LOW    
    }
	ke_timer_clear(APP_BATT_ALERT_TIMER, TASK_APP);
    
#ifdef CUSTOM_BATTERY_LEVEL_MEASUREMENTS___BOOST_MODE_CONFIGURATION
    if (bat_led_state == 0)
        app_restore_sleep_mode(); 
#endif //CUSTOM_BATTERY_LEVEL_MEASUREMENTS___BOOST_MODE_CONFIGURATION
	
	bat_led_state = 0;


}
Exemplo n.º 20
0
/**
 ****************************************************************************************
 * @brief Handles Battery Alert timer
 *
 * @param[in] msgid     Id of the message received.
 * @param[in] param     Pointer to the parameters of the message.
 * @param[in] dest_id   ID of the receiving task instance (TASK_GAP).
 * @param[in] src_id    ID of the sending task instance.
 *
 * @return If the message was consumed or not.
 ****************************************************************************************
 */
int app_batt_alert_timer_handler(ke_msg_id_t const msgid,
                                        void const *param,
										ke_task_id_t const dest_id,
										ke_task_id_t const src_id)
{
    //Read LED GPIO state
    if(bat_lvl_alert_used)
    {		
		if (bat_led_state)
		{
            GPIO_SetInactive( bat_led_port, bat_led_pin);            	
			bat_led_state = 0;
			app_timer_set(APP_BATT_ALERT_TIMER, dest_id, 20);
		}
		else
		{
            GPIO_SetActive( bat_led_port, bat_led_pin);
			bat_led_state = 1;
			app_timer_set(APP_BATT_ALERT_TIMER, dest_id, 5);
		}
    }
		
    return (KE_MSG_CONSUMED);
}
Exemplo n.º 21
0
/**
 ****************************************************************************************
 * @brief SPI_439 initialization
 *
 * Should only be called once after power reset of 439, do not call this twice.
 *
 * @return void
 ****************************************************************************************
 */
void spi_439_init()
{
    #if ( DESIGN_0 || DESIGN_1 )
    GPIO_SetInactive( GPIO_PORT_2, GPIO_PIN_2 );   // Power on the 439, by setting MUTE_LDO = 0    
    #elif ( DESIGN_2 || DESIGN_3 )
    GPIO_SetInactive( GPIO_PORT_1, GPIO_PIN_3 );   // Power on the 439, by setting MUTE_LDO = 0    
    #endif
   
    SetBits16(SPI_CTRL_REG, SPI_ON, 0);			// switch off SPI block
    SPI_Pad_t spi_cs_pad;

    #if ( DESIGN_0 || DESIGN_1 )
    spi_cs_pad.port = GPIO_PORT_0;
    spi_cs_pad.pin  = GPIO_PIN_3;
    #elif ( DESIGN_2 || DESIGN_3 )
    spi_cs_pad.port = GPIO_PORT_0;
    spi_cs_pad.pin  = GPIO_PIN_2;
    #endif
    
    spi_init(&spi_cs_pad, SPI_MODE_16BIT, SPI_ROLE_MASTER,
             SPI_CLK_IDLE_POL_LOW, SPI_PHA_MODE_0, SPI_MINT_DISABLE, SPI_XTAL_DIV_14);  // SPI_XTAL_DIV_2=8MHZ, SPI_XTAL_DIV_8=2MHZ
               
    /*
    ** First try to read our magic word. It should be 1A30. If so, skip the clock initializations. 
    ** Otherwise, we are coming from cold boot.
    */
    {
    #ifdef JOH_CLK_SETTINGS
        /*  
        ** clk=16 Mhz from the 580 => set 439 PLL for Fsys = 46.08 MHz
        ** This means:
        ** - SC14439_CLK_CTRL_REG=0,0x12, 0x1A 
        ** - SC14439_PLL_DIV_REG = 0x2A19, so VD/VX=(72/25)*16Mhz = 46.08 Mhz Fsys clock
        ** - SC14439_CLK_CTRL_REG  , turn on PLL
        ** - SC14439_PER_DIV_REG = 4
        ** - SC14439_CODEC_DIV_REG = 20, so ClodecClk=46.08/20=2.304 Mhz
        */

        SetWord439(SC14439_CLK_CTRL_REG, 0);    
        SetWord439(SC14439_PLL_DIV_REG,  0x2A19);    /* VD/XD=(72/25)*16MHz = 46.08 Mhz Fsys. VD=72=6x12=01.0101; XD=25=00.11001, total = 0010.1010.0001.1001 */
        SetWord439(SC14439_CLK_CTRL_REG, 0x12);    
        SetWord439(SC14439_PER_DIV_REG,  4);           /* see calculation in DS SC14439, per_div<4 */
    #else
        /*  
        ** clk=16 Mhz from the 580 => set 439 PLL for Fsys = 39.183 MHz
        ** This means:
        ** - SC14439_CLK_CTRL_REG=0,0x12, 0x1A 
        ** - SC14439_PLL_DIV_REG = 0x2A19, so VD/VX=(120/49)*16Mhz = 39.183 Mhz Fsys clock
        ** - SC14439_CLK_CTRL_REG  , turn on PLL
        ** - SC14439_PER_DIV_REG = 4
        ** - SC14439_CODEC_DIV_REG = 20, so ClodecClk=46.08/20=2.304 Mhz
        */

        SetWord439(SC14439_CLK_CTRL_REG, 0);    
        SetWord439(SC14439_PLL_DIV_REG,  0x3631);    /* VD/XD=(120/49)*16MHz =  39.183 Mhz Fsys. VD=120=10x12=01.1011; XD=49=01.10001 */
        SetWord439(SC14439_CLK_CTRL_REG, 0x12);    
        SetWord439(SC14439_PER_DIV_REG,  4);           /* see calculation in DS SC14439, per_div<4 */
    #endif
    
        SetWord439(SC14439_BAT_CTRL_REG, 2);              /* VDDIO 2.25..2.75V gr: ok up to 3.45 V  Not required - default value is valid */
        SetWord439(SC14439_CODEC_VREF_REG, 0x0000);       //make VREF settle faster TODO CHECK
        SetWord439(SC14439_CODEC_ADDA_REG, 0x040e);
        
    #if ( DESIGN_0 || DESIGN_1 )
        SetWord439(SC14439_CODEC_MIC_REG,  0x1081);    	  /* Amplifier Active*/
    #elif ( DESIGN_2 || DESIGN_3 )
        SetWord439(SC14439_CODEC_MIC_REG,  0x1041);    	  /* Amplifier Active - Less Gain */
    #endif
        
    #if ( DESIGN_0 || DESIGN_1 )
        spi439_delay(1500);                               //wait for PLL to settle
        SetWord439(SC14439_CLK_CTRL_REG, 0x1A);    
        spi439_delay(100); //wait 16 spi cycles
    #elif ( DESIGN_2 || DESIGN_3 )
        spi439_delay(2000);                               //wait for PLL to settle
        SetWord439(SC14439_CLK_CTRL_REG, 0x1A);    
        spi439_delay(100); //wait 16 spi cycles
    #endif
    }
    
    /*
    ** 439 Codec initialization
    **
    */   
    #ifdef JOH_CLK_SETTINGS
    SetWord439(SC14439_CODEC_DIV_REG, 0x14);       /* codec clk divider 46.08/20 = 2.304 MHz */
    #else
    SetWord439(SC14439_CODEC_DIV_REG, 0x11);       /* codec clk divider Fsys/17 = 2.304 MHz */
    #endif
    
    spi439_delay(100); //wait a while
    SetWord439(SC14439_CODEC_ADDA_REG, 0x0006);
    SetWord439(SC14439_CODEC_VREF_REG, 0x0000); 

    /*
    ** Setup DMA on 439
    ** DMA will collect 80 samples from CODEC and put them in Shared RAM at address 0x0CD8, in circular buffer
    ** and continue indefenitely.
    ** 
    ** The DMA buffer on the 439 is set to 80 samples = 160 bytes (Note hat DMA0_LEN is in bytes)
    ** Start address is 0xCD8. Second part of buffer starts at 0xD28
    **
    */
    SetWord439(SC14439_DMA0_LEN_REG,SC14439_DMA_LEN);
    SetWord439(SC14439_DMA0_A_STARTL_REG,SC14439_DMA_DST_ADDR);
    SetWord439(SC14439_DMA0_A_IDX_REG,0);
    SetWord439(SC14439_DMA0_B_STARTL_REG,SC14439_CODEC_IN_OUT_REG);
    SetWord439(SC14439_DMA0_B_IDX_REG,0);
    SetWord439(SC14439_DMA0_CTRL_REG,0x062D);   // SYNC_SEL=0, DREQ_LEVEL=0,CIRUCLAR=1., AINC=10,BINC=00 DREQ_MODE=1, RSRV, IND=1, DIR=1, RSRVD, DMA_ON=1 = 0000.0110.0010.1101
    
    NVIC_SetPriority(SPI_IRQn,1);
    NVIC_EnableIRQ(SPI_IRQn);
}
Exemplo n.º 22
0
void spi3wire_cs_low (void)
{
    GPIO_SetInactive(cs.port, cs.pin);                            // set CS low
}