Пример #1
0
void setup()
{
    //
    // Configure PLL, disable WD, enable peripheral clocks.
    //
    Device_init();

    //
    // Disable pin locks and enable internal pullups.
    //
    Device_initGPIO();

    // Initialize Pins as desired
    SCI_Init();
    ADC_Init();
    EQEP_Init();
    GPIO_Init();
    UltraSonic_GPIO_Init();
    UltraSonic_TMR_Init();


    //
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    //
    EINT;
    ERTM;
}
Пример #2
0
Effect* new_Effect(void)
{
    Effect* eff = memory_alloc_item(Effect);
    if (eff == NULL)
        return NULL;

    eff->out_iface = NULL;
    eff->in_iface = NULL;
    eff->connections = NULL;
    eff->dsps = NULL;

    if (!Device_init(&eff->parent, false))
    {
        del_Effect(eff);
        return NULL;
    }

    Device_set_state_creator(&eff->parent, Effect_create_state);
    Device_set_reset(&eff->parent, Effect_reset);
    Device_register_set_audio_rate(&eff->parent, Effect_set_audio_rate);
    Device_register_update_tempo(&eff->parent, Effect_update_tempo);
    Device_register_set_buffer_size(&eff->parent, Effect_set_buffer_size);
    //Device_set_sync(&eff->parent, Effect_sync);
    Device_set_process(&eff->parent, Effect_process);

    for (int port = 0; port < KQT_DEVICE_PORTS_MAX; ++port)
    {
        Device_register_port(&eff->parent, DEVICE_PORT_TYPE_RECEIVE, port);
        Device_register_port(&eff->parent, DEVICE_PORT_TYPE_SEND, port);
    }

    eff->out_iface = new_Effect_interface();
    eff->in_iface = new_Effect_interface();
    eff->dsps = new_DSP_table(KQT_DSPS_MAX);
    if (eff->out_iface == NULL || eff->in_iface == NULL || eff->dsps == NULL)
    {
        del_Effect(eff);
        return NULL;
    }

    for (int port = 0; port < KQT_DEVICE_PORTS_MAX; ++port)
    {
        Device_register_port(&eff->out_iface->parent,
                             DEVICE_PORT_TYPE_SEND, port);
        Device_register_port(&eff->in_iface->parent,
                             DEVICE_PORT_TYPE_SEND, port);
    }
    Device_register_port(&eff->out_iface->parent,
                         DEVICE_PORT_TYPE_RECEIVE, 0);

    //fprintf(stderr, "New effect %p\n", (void*)eff);

    return eff;
}
Пример #3
0
Module* new_Module(void)
{
    Module* module = memory_alloc_item(Module);
    if (module == NULL)
        return NULL;

    if (!Device_init(&module->parent, false))
    {
        memory_free(module);
        return NULL;
    }

    Device_set_existent(&module->parent, true);

    // Clear fields
    module->random_seed = 0;
    module->songs = NULL;
    module->album_is_existent = false;
    module->track_list = NULL;
    module->ch_defs = NULL;
    module->pats = NULL;
    module->au_map = NULL;
    module->au_controls = NULL;
    module->au_table = NULL;
    module->connections = NULL;
    module->is_dc_blocker_enabled = true;
    module->mix_vol_dB = COMP_DEFAULT_MIX_VOL;
    module->mix_vol = exp2(module->mix_vol_dB / 6);
    module->force_shift = 0;
    module->env = NULL;
    module->bind = NULL;
    for (int i = 0; i < KQT_SONGS_MAX; ++i)
        module->order_lists[i] = NULL;
    for (int i = 0; i < KQT_TUNING_TABLES_MAX; ++i)
        module->tuning_tables[i] = NULL;

    // Create fields
    module->songs = new_Song_table();
    module->pats = new_Pat_table(KQT_PATTERNS_MAX);
    module->au_controls = new_Bit_array(KQT_CONTROLS_MAX);
    module->au_table = new_Au_table(KQT_AUDIO_UNITS_MAX);
    if (module->songs == NULL           ||
            module->pats == NULL        ||
            module->au_controls == NULL ||
            module->au_table == NULL)
    {
        del_Module(module);
        return NULL;
    }

    module->env = new_Environment();
    if (module->env == NULL)
    {
        del_Module(module);
        return NULL;
    }

    Streader* conn_sr = Streader_init(STREADER_AUTO, NULL, 0);
    module->connections =
        new_Connections_from_string(conn_sr, false, module->au_table, &module->parent);
    if (module->connections == NULL)
    {
        del_Module(module);
        return NULL;
    }

    return module;
}
Пример #4
0
  void main(void)
{
	int i1=0;
	int count10S = 0;
	Device_init();
        disable_irq(PIT0_IRQn);
        systick_delay_ms(50);
        FLOAT_LDC_init(SPI1);
        systick_delay_ms(50);
        FLOAT_LDC_init(SPI0);
        systick_delay_ms(1000);
        uart_init(UART3,115200);
        key_init(0);
        key_init(1);
        key_init(2);
        //LDC_EVM_TEST();
        
        //Speed_Ctl_Init(short point_value, double dKpp, double dKii, double dKdd);
        
      while(1)
      {
        //value_collect();
    
       LCD_P6x8Str(0,2,"Rmax Lmin");
        printf("Rmax Rmin\r\n");
        systick_delay_ms(1500);
        i1=50;
        
        while(i1--)
       {
           adjustment[2]=(float)filter(SPI1)/10;//右max
           LCD_BL(55,2,(uint16)adjustment[2]);
           printf("%d\r\n",adjustment[2]);
       }
        
       i1=50;
       while(i1--)
       {
          adjustment[1]=(float)filter(SPI0)/10;//左min
          LCD_BL(90,2,(uint16)adjustment[1]);
          printf("%d\r\n",adjustment[1]);
       }
       
       LCD_BL(55,2,(uint16)adjustment[1]);
       LCD_BL(90,2,(uint16)adjustment[2]);      
        
        
    
       LCD_P6x8Str(0,4,"Lmax Rmin");
       printf("Lmax Rmin\r\n");
       systick_delay_ms(1500);
       i1=50;
       while(i1--)
       {
       adjustment[3]=(float)filter(SPI1)/10;//右min
       LCD_BL(55,4,(uint16)adjustment[3]);
       printf("%d\r\n",adjustment[3]);
       }
        
       i1=50;
       while(i1--)
       {
        adjustment[4]=(float)filter(SPI0)/10;//左max
        LCD_BL(90,4,(uint16)adjustment[4]);
        printf("%d\r\n",adjustment[4]);
       }
       
       LCD_BL(55,4,(uint16)adjustment[4]);
       LCD_BL(90,4,(uint16)adjustment[3]);
       
       if(adjustment[1]<=adjustment[3])
         adjustment[5]=adjustment[1];//次小值
       else
         adjustment[5]=adjustment[3];//次小值
       
       if(adjustment[2]>=adjustment[4])
         adjustment[6]=adjustment[2];//次大值
       else
         adjustment[6]=adjustment[4];//次大值
       
       divisor = (adjustment[2] - adjustment[3])/60;                              //48 //50
       divisor2 = (adjustment[4] - adjustment[1])/59;                             //48 //45
       
       zengfuzhi =  (adjustment[2] - adjustment[3])/(adjustment[4] - adjustment[1]);
//       for(int i=0;i<10;i++)
//       {
//         printf("%d\r\n",adjustment[i]);
//       }
//       systick_delay_ms(1000);
       
       
          
       LCD_P6x8Str(0,6,"Mid value");
        i1 = 50;
       systick_delay_ms(1500);
       while(i1--)
       {
        adjustment[7]=(float)filter(SPI0)/10;//左
        adjustment[8]=(float)filter(SPI1)/10;//右
        LCD_BL(55,6,(uint16)adjustment[7]);
        LCD_BL(90,6,(uint16)adjustment[8]);
       }
            if(adjustment[7]>=adjustment[8])
       { flag=1;
       adjustment[0]=adjustment[7]-adjustment[8];
       }
       else
       {
         flag=0;
       adjustment[0]=adjustment[8]-adjustment[7]; 
       }
       
       LCD_Fill(0x00);
       
       Out_side_collect();
       
       LCD_Fill(0x00);
       
       adjustment_change();
       
       enable_irq(PIT0_IRQn);
          while(1)
          { 
                  
                  if(PIT_1sFlag == 1)
                  {
                        gpio_turn(PTD4);
                        PIT_1sFlag = 0;
                        count10S ++;
                  }
                  if(key_check(2) == 0)
                  {
                    LCD_Fill(0x00);
                    Motor_stop();
                    break;
                  }
                  else
                  {
                    if(PIT_5msFlag == 1)
                    {
                      LDC_get();
                      PIT_5msFlag = 0;
                      Steering_Change();
                    }
                    if(count10S > 10)
                    {  
                      if(gpio_get(PTC4) == 0)
                      {
                        while(1)
                        {
                          Motor_stop();
                          Steering_Change();
                        }
                      }
                    }
                    if(PIT_10msFlag == 1)
                    {
                      Quad_count();
                      now = (float)guad_val;
                      Motor_PID(now);
                      PIT_10msFlag = 0;
                      
                    }
                    if(PIT_20msFlag == 1)
                    {

                      PIT_20msFlag = 0;
                    }
                    if(PIT_50msFlag == 1)
                    {
                      
                      //Result_collect();
                      PIT_50msFlag = 0;
                    }
 
                    
                    //printf("guad_val:%d \r\n",(guad_val));
                    
                    //TEST_display();
                    speed_control();
                    
                    //key_choice();
                    uint16 i23 = gpio_get(PTC4); 
                    
                    //LCD_BL(50,2,(uint16)(i23));
                  }
          }
      }
}