/** * * main cycle of following algorithm * */ int MainCycle() { struct work_unit* w=algo.head; do { if(w==NULL) { syslog(LOG_ERR, "NULL алгоритм\n"); go_out(); }; fill_time(); switch(w->type) { case 't': play_dtmf(time_buffer); break; case 'v': play_voice(time_buffer); break; case 's': play_wav(w->param); break; case 'p': play_pause(w->param); break; default: syslog(LOG_ERR, "Ошибка в структуре алгоритма работы: %c\n", w->type); go_out(); break; }; w=w->next_unit; } while(w!=NULL); return(0); }
void TextToSpeech::retalk() { std::cout << str_ << std::endl; make_wav(str_, fperiod_); play_wav(); remove_wav(); }
static gpointer play_thread_wav(gpointer data) { struct con_win *cwin = (struct con_win *)data; play_wav(cwin); return NULL; }
void TextToSpeech::talk(const std::string& str, int fperiod) { // retalk の為に覚えておく str_ = str; fperiod_ = fperiod; std::cout << str << std::endl; make_wav(str, fperiod); play_wav(); remove_wav(); }
int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr,"usage: playback <file>\n"); // return -1; } return play_wav(argv[1]); }
int time_audio(unsigned int **arr) { double timer,freq,total; int f = alt_timestamp_start(); play_wav(arr); timer = alt_timestamp(); freq = alt_timestamp_freq(); total = (int)((timer * 1000)/freq); return total; }
void make_arena_hostile(void) { if (game.type == GAME_TIME_ATTACK || game.type == GAME_TIME_ATTACK_COOP) return; explode_all_pickups(); arena.hostile = 1; // arena.colour3 = COLOUR_RED1; // calculate_beat(); open_eyes(); shake_all_screens(150); play_wav(NWAV_BANG); // send_message(0, "Defences} On}-Line}!", STYLE_HURRY); // send_message(1, "Defences} On}-Line}!", STYLE_HURRY); }
void extra_ship(void) { if (game.ships_left <= 20) { game.ships_left ++; play_wav(NWAV_EXTRA); if (game.users == 1) { // send_message(game.single_player, "Extra!", STYLE_UPGRADE5); } else { // send_message(0, "Extra!", STYLE_UPGRADE5); // send_message(1, "Extra!", STYLE_UPGRADE5); } } }
int detect_collision_actor_pickups(int a) { int x2 = actor[a].x - actor[a].x_speed; int y2 = actor[a].y - actor[a].y_speed; int i; char destroy = 0; for (i = 0; i < NO_PICKUPS; i ++) { if (pickup[i].type == PICKUP_NONE) continue; if (hypot(actor[a].x - pickup[i].x, actor[a].y - pickup[i].y) <= actor[a].radius + pickup[i].radius || hypot(x2 - pickup[i].x, y2 - pickup[i].y) <= actor[a].radius + pickup[i].radius) { destroy = 1; switch(pickup[i].type) { case PICKUP_PRESYMBOL: destroy = 0; break; case PICKUP_PRESECONDARY: destroy = 0; break; case PICKUP_SECONDARY: actor[a].secondary = pickup[i].subtype; actor[a].secondary_burst = 0; actor[a].secondary_burst_recycle = 0; play_wavf(NWAV_REPAIR, 1700); break; case PICKUP_SQUARE: // gain_upgrade_points(a, 1); destroy = gain_symbol(a, pickup[i].subtype, SYMBOL_SQUARE); if (destroy) // play_soundf(WAV_PICKUP_UPGRADE, 1000); play_wavf(NWAV_SYMBOL, 1000); break; case PICKUP_TRIANGLE: destroy = gain_symbol(a, pickup[i].subtype, SYMBOL_TRIANGLE); // gain_upgrade_points(a, 2); if (destroy) play_wavf(NWAV_SYMBOL, 1700); // play_soundf(WAV_PICKUP_UPGRADE, 1500); break; case PICKUP_CIRCLE: destroy = gain_symbol(a, pickup[i].subtype, SYMBOL_CIRCLE); // gain_upgrade_points(a, 3); if (destroy) play_wavf(NWAV_SYMBOL, 1300); // play_soundf(WAV_PICKUP_UPGRADE, 2000); break; case PICKUP_REPAIR: // actor[a].armour = actor[a].max_armour; actor[a].repairing += 150; // actor[a].max_armour / 10; play_wav(NWAV_REPAIR); break; case PICKUP_GRACE: actor[a].grace_period = 333; break; case PICKUP_SHIP: extra_ship(); break; } if (destroy) pickup_explodes(i, 1); } } return -1; }
// This is the kitten's callback, // all its actions take place here void kitten_move(gpointer kittyp) { Kitten * kitty; Entity * player; Level world; TimeTracker * time; EntitySet * others; float x, y; float px, py; float dx, dy; unsigned int dir; Entity * body; Player * dude; kitty = (Kitten *) kittyp; player = kitty->player; world = kitty->world; time = kitty->time; others = kitty->others; body = kitty->body; entity_position(body, &x, &y); entity_position(player, &px, &py); dir = look(x, y, px, py); dx = px - x; dy = py - y; entity_set_direction(body, dx, dy); entity_move(body, world, time, others); entity_get_direction(body, &dx, &dy); if (collision(body, x + dx, y + dy, others) == player) { if (expired(kitty->claw_timer)) { play_wav(kitty->claw); } if (expired(kitty->attack_timer)) { dude = entity_user_data(player); player_hurt(dude); } if (dir == LEFT) { set_animation(body, "attack_left"); } else if (dir == RIGHT) { set_animation(body, "attack_right"); } else if (dir == UP) { set_animation(body, "attack_up"); } else if (dir == DOWN) { set_animation(body, "attack_down"); } } else if (dir == LEFT) { set_animation(body, "left"); } else if (dir == RIGHT) { set_animation(body, "right"); } else if (dir == UP) { set_animation(body, "up"); } else if (dir == DOWN) { set_animation(body, "down"); } }
void *play_wav_d(void *file) { play_wav((char *)file); return NULL; }
// The player is alive void alive(Player * me) { InputState * is; Camera * cam; EntitySet * others; Level world; unsigned int mousex; unsigned int mousey; float playerx, playery; float fake_lookx, fake_looky; float lookx, looky; unsigned int dir; float x, y; float dx = 0; float dy = 0; gboolean shoot; gboolean firing; Entity * target; is = me->is; cam = me->cam; others = me->others; world = me->world; firing = mouse_press(is); shoot = expired(me->attack_timer); // Get the mouse position mouse_position(is, &mousex, &mousey); // Get the mouse position with regards to the level. camera_inverse_transform(cam, mousex, mousey, &fake_lookx, &fake_looky); lookx = fake_lookx / square_size; looky = fake_looky / square_size; entity_position(me->body, &playerx, &playery); dir = look(playerx, playery, lookx, looky); // Set the direction of the player with regards to key presses if (key_down(is, SDLK_a) || key_down(is, SDLK_LEFT)) { dx = -1; } else if (key_down(is, SDLK_d) || key_down(is, SDLK_RIGHT)) { dx = 1; } if (key_down(is, SDLK_w) || key_down(is, SDLK_UP)) { dy = -1; } else if (key_down(is, SDLK_s) || key_down(is, SDLK_DOWN)) { dy = 1; } entity_set_direction(me->body, dx, dy); // Try to shoot a KITTY! if (firing) { if (shoot) { play_wav(me->fire); entity_position(me->body, &x, &y); if (can_see(world, x, y, lookx, looky)) { target = collision(me->body, lookx, looky, others); if (target) { entity_destroy(target); me->score ++; } } } if (dx != 0 || dy != 0) { if (dir == LEFT) { set_animation(me->body, (char *) "shoot_walk_left"); } else if (dir == RIGHT) { set_animation(me->body, (char *) "shoot_walk_right"); } else if (dir == UP) { set_animation(me->body, (char *) "shoot_walk_up"); } else if (dir == DOWN) { set_animation(me->body, (char *) "shoot_walk_down"); } } else { if (dir == LEFT) { set_animation(me->body, (char *) "shoot_idle_left"); } else if (dir == RIGHT) { set_animation(me->body, (char *) "shoot_idle_right"); } else if (dir == UP) { set_animation(me->body, (char *) "shoot_idle_up"); } else if (dir == DOWN) { set_animation(me->body, (char *) "shoot_idle_down"); } } } else { if (dx != 0 || dy != 0) { if (dir == LEFT) { set_animation(me->body, (char *) "walk_left"); } else if (dir == RIGHT) { set_animation(me->body, (char *) "walk_right"); } else if (dir == UP) { set_animation(me->body, (char *) "walk_up"); } else if (dir == DOWN) { set_animation(me->body, (char *) "walk_down"); } } else { if (dir == LEFT) { set_animation(me->body, (char *) "idle_left"); } else if (dir == RIGHT) { set_animation(me->body, (char *) "idle_right"); } else if (dir == UP) { set_animation(me->body, (char *) "idle_up"); } else if (dir == DOWN) { set_animation(me->body, (char *) "idle_down"); } } } }
void cmd_handle(void){ unsigned char cmd; unsigned char cmd_param[8]; int i; cmd = uart1_receive(); uart1_send_char(cmd); // uart2_send_char('O'); // uart3_send_char('K'); switch(cmd){ case CMD_FORWARD://前进 car_forward(); break; case CMD_BACK ://后退 car_back(); break; case CMD_LEFT://向左移动 car_left(); break; case CMD_RIGHT://向右移动 car_right(); break; case CMD_STOP://制动 car_stop(); break; case CMD_INIT://初始化 car_init(); break; case CMD_STANDBY://待机 car_standby(); break; case CMD_CIRCLE1://转 car_circle(1); break; case CMD_CIRCLE2://反转 car_circle(0); break; case CMD_MOTOR_SET://设置参数 for(i=0;i<8;i++){ cmd_param[i]=uart1_receive(); } car_set(cmd_param); for(i=0;i<8;i++){ uart1_send_char(cmd_param[i]); } break; case CMD_RESUME://恢复 car_resume(); break; case CMD_POWER_SET: for(i=0;i<2;i++){ cmd_param[i]=uart1_receive(); } power_set(cmd_param); for(i=0;i<2;i++){ uart1_send_char(cmd_param[i]); } break; case CMD_STEER_SET: for(i=0;i<3;i++){ cmd_param[i]=uart1_receive(); } steering_set(cmd_param); for(i=0;i<3;i++){ uart1_send_char(cmd_param[i]); } break; case CMD_STEER_SHOW: steering_show(); break; case CMD_STEER_SET_INIT: steering_set_init(); break; case CMD_PLAY_WAV: cmd_param[0]=uart1_receive(); play_wav(cmd_param[0]); break; default:break; } }
int main(int argc, char **argv) { int option_index = 0; int c; int ch = 2; int rate = 44100; char *mmap = "N"; char *device = "hw:0,0"; char *filename; if (argc <2) { printf("Usage: aplay [options] <file>\n" "options:\n" "-D <hw:C,D> -- Alsa PCM by name\n" "-M -- Mmap stream\n" "-P -- Hostless steam[No PCM]\n" "-C -- Channels\n" "-R -- Rate\n" "-V -- verbose\n" "<file> \n"); return 0; } while ((c = getopt_long(argc, argv, "PVMD:R:C:", long_options, &option_index)) != -1) { switch (c) { case 'P': pcm_flag = 0; break; case 'V': debug = 1; break; case 'M': mmap = "M"; break; case 'D': device = optarg; break; case 'R': rate = (int)strtol(optarg, NULL, 0); break; case 'C': ch = (int)strtol(optarg, NULL, 0); break; default: printf("Usage: aplay [options] <file>\n" "options:\n" "-D <hw:C,D> -- Alsa PCM by name\n" "-M -- Mmap stream\n" "-P -- Hostless steam[No PCM]\n" "-V -- verbose\n" "-C -- Channels\n" "-R -- Rate\n" "<file> \n"); return -EINVAL; } } filename = (char*) calloc(1, 30); if (!filename) { fprintf(stderr, "Aplay:Failed to allocate filename!"); return -ENOMEM; } if (optind > argc - 1) { filename = NULL; } else { strcpy(filename, argv[optind++]); } if (pcm_flag) { play_wav(mmap, rate, ch, device, filename); } else { play_wav(mmap, rate, ch, device, "dummy"); } free(filename); return 0; }
LIBLOCAL void tux_sound_flash_state_machine_call(void) { bool rf_state = false; float full_time_sec = 0.0; data_frame frame = {0, 0, 0, 0}; unsigned char curr_track_for_event = 0; /* Check f*x connection and radio connection */ if (reflash_info.current_state != SRS_STDBY) { rf_state = tux_usb_get_rf_state(); if ((!tux_usb_connected()) || (!rf_state)) { reflash_info.error = SRE_RF_OFFLINE; reflash_info.current_state = SRS_FINISH; } } switch (reflash_info.current_state) { case SRS_STDBY: break; case SRS_INIT: /* Disabling commands parsing */ tux_cmd_parser_set_enable(false); /* Send begin flashing event with the fulltime of processing */ full_time_sec = 10.0 + (reflash_info.full_size / 8000.0); full_time_sec += reflash_info.wav_count * 0.97; tux_sw_status_set_floatvalue(SW_ID_SOUND_REFLASH_BEGIN, full_time_sec, true); tux_sw_status_set_strvalue(SW_ID_SOUND_REFLASH_END, STRING_VALUE_NDEF, true); /* Goto SRS_ERASE state */ reflash_info.current_state = SRS_ERASE; break; case SRS_ERASE: /* Leds pulsing */ tux_leds_cmd_set(LED_LEFT, 0.0, NONE, 0, 0); tux_leds_cmd_set(LED_RIGHT, 1.0, NONE, 0, 0); tux_leds_cmd_pulse(LED_BOTH, 0.0, 1.0, 255, 1.0, FADE_DURATION, 0.5, 0); /* Send erase cmd */ log_info("Sound reflash: Erasing"); frame[0] = ERASE_FLASH_CMD; if (!tux_usb_send_to_tux(frame)) { reflash_info.error = SRE_USB_ERROR; reflash_info.current_state = SRS_FINISH; break; } /* Wait that the flash has been erased */ sleep(10); /* Set first track to write */ reflash_info.current_wav = 0; /* Goto SRS_WRITE state */ reflash_info.current_state = SRS_WRITE; break; case SRS_WRITE: /* Send store sound command */ log_info("Sound reflash: Store track (%d of %d)", reflash_info.current_wav + 1, reflash_info.wav_count); frame[0] = STORE_SOUND_CMD; if (!tux_usb_send_to_tux(frame)) { reflash_info.error = SRE_USB_ERROR; reflash_info.current_state = SRS_FINISH; break; } curr_track_for_event = reflash_info.current_wav + 1; tux_sw_status_set_intvalue(SW_ID_SOUND_REFLASH_CURRENT_TRACK, curr_track_for_event, true); usleep(200000); /* Play current wav track */ if (!play_wav(reflash_info.wav_path[reflash_info.current_wav])) { frame[0] = CONFIRM_STORAGE_CMD; frame[1] = 0; if (!tux_usb_send_to_tux(frame)) { reflash_info.error = SRE_USB_ERROR; reflash_info.current_state = SRS_FINISH; break; } reflash_info.error = SRE_WAV_ERROR; reflash_info.current_state = SRS_FINISH; break; } /* Send confirm track command */ usleep(200000); frame[0] = CONFIRM_STORAGE_CMD; frame[1] = 1; if (!tux_usb_send_to_tux(frame)) { reflash_info.error = SRE_USB_ERROR; reflash_info.current_state = SRS_FINISH; break; } usleep(100000); /* Set next track to write */ reflash_info.current_wav += 1; /* If the next track is out of limit, Goto SRS_FINISH state */ if (reflash_info.current_wav >= reflash_info.wav_count) { reflash_info.current_state = SRS_FINISH; } break; case SRS_FINISH: /* Enabling commands parsing */ tux_cmd_parser_set_enable(true); /* Leds stop */ tux_leds_cmd_set(LED_BOTH, 1.0, NONE, 0, 0); /* Send end of flashing event */ full_time_sec = 0.0; tux_sw_status_set_floatvalue(SW_ID_SOUND_REFLASH_BEGIN, full_time_sec, false); switch (reflash_info.error) { case SRE_NO_ERROR: tux_sw_status_set_strvalue(SW_ID_SOUND_REFLASH_END, STRING_VALUE_NO_ERROR, true); log_info("Sound reflash: Finish (%s)", STRING_VALUE_NO_ERROR); /* Play first track */ tux_sound_flash_cmd_play(1, 100.0); break; case SRE_RF_OFFLINE: tux_sw_status_set_strvalue(SW_ID_SOUND_REFLASH_END, STRING_VALUE_ERROR_RF_OFFLINE, true); log_info("Sound reflash: Finish (%s)", STRING_VALUE_ERROR_RF_OFFLINE); break; case SRE_WAV_ERROR: tux_sw_status_set_strvalue(SW_ID_SOUND_REFLASH_END, STRING_VALUE_ERROR_WAV_ERROR, true); log_info("Sound reflash: Finish (%s)", STRING_VALUE_ERROR_WAV_ERROR); break; case SRE_USB_ERROR: tux_sw_status_set_strvalue(SW_ID_SOUND_REFLASH_END, STRING_VALUE_ERROR_USB, true); log_info("Sound reflash: Finish (%s)", STRING_VALUE_ERROR_USB); break; } /* Goto SRS_STDBY state */ reflash_info.current_state = SRS_STDBY; break; } }
int mymain(void) { int i; for (i = 0; i < 0x100000; i++) { *(char *)(0x30000000 + i) = 0; } #if 0 //*(volatile unsigned int *)0x48000000 = 0x2211d120; //*(volatile unsigned int *)0x48000004 = 0x00000700; //*(volatile unsigned int *)0x48000008 = 0x00000700; //*(volatile unsigned int *)0x4800000c = 0x00000700; //*(volatile unsigned int *)0x48000010 = 0x00001f4c; //*(volatile unsigned int *)0x48000014 = 0x00000700; //*(volatile unsigned int *)0x48000018 = 0x00000700; //*(volatile unsigned int *)0x4800001c = 0x00018005; //*(volatile unsigned int *)0x48000020 = 0x00018005; //*(volatile unsigned int *)0x48000024 = 0x008e0459; //*(volatile unsigned int *)0x48000028 = 0x00000032; *(volatile unsigned int *)0x4800002c = 0x00000030; //*(volatile unsigned int *)0x48000030 = 0x00000030; ; #endif #if 0 *(volatile unsigned int *)0x4c000000 = 0x00ffffff; *(volatile unsigned int *)0x4c000004 = 0x00044011; *(volatile unsigned int *)0x4c000008 = 0x00038042; *(volatile unsigned int *)0x4c00000c = 0x00fffff0; *(volatile unsigned int *)0x4c000010 = 0x00000004; *(volatile unsigned int *)0x4c000014 = 0x00000007; *(volatile unsigned int *)0x4c000018 = 0x00000000; *(volatile unsigned int *)0x4c00001c = 0x00000000; *(volatile unsigned int *)0x4c000020 = 0x00ffffff; *(volatile unsigned int *)0x4c000024 = 0x00044011; ; #endif #if 0 *(volatile unsigned int *)0x4d000000 = 0x00000000; *(volatile unsigned int *)0x4d000004 = 0x00000000; *(volatile unsigned int *)0x4d000008 = 0x00000000; *(volatile unsigned int *)0x4d00000c = 0x00000000; *(volatile unsigned int *)0x4d000010 = 0x00000000; *(volatile unsigned int *)0x4d000014 = 0x00000000; *(volatile unsigned int *)0x4d000018 = 0x00000000; *(volatile unsigned int *)0x4d00001c = 0x00000000; *(volatile unsigned int *)0x4d000020 = 0x00000000; *(volatile unsigned int *)0x4d000024 = 0x00000000; *(volatile unsigned int *)0x4d000028 = 0x00000000; *(volatile unsigned int *)0x4d00002c = 0x0000a5a5; *(volatile unsigned int *)0x4d000030 = 0x0ba5da65; *(volatile unsigned int *)0x4d000034 = 0x000a5a5f; *(volatile unsigned int *)0x4d000038 = 0x00000d6b; *(volatile unsigned int *)0x4d00003c = 0x0eb7b5ed; *(volatile unsigned int *)0x4d000040 = 0x00007dbe; *(volatile unsigned int *)0x4d000044 = 0x0007ebdf; *(volatile unsigned int *)0x4d000048 = 0x07fdfbfe; *(volatile unsigned int *)0x4d00004c = 0x00000000; *(volatile unsigned int *)0x4d000050 = 0x00000000; *(volatile unsigned int *)0x4d000054 = 0x00000000; *(volatile unsigned int *)0x4d000058 = 0x00000001; *(volatile unsigned int *)0x4d00005c = 0x00000003; *(volatile unsigned int *)0x4d000060 = 0x00000ce6; *(volatile unsigned int *)0x4d000064 = 0x00000000; *(volatile unsigned int *)0x4d000068 = 0x00000000; *(volatile unsigned int *)0x4d00006c = 0x00000000; *(volatile unsigned int *)0x4d000070 = 0x00000000; *(volatile unsigned int *)0x4d000074 = 0x00000000; ; #endif #if 0 *(volatile unsigned int *)0x56000000 = 0x007fffff; *(volatile unsigned int *)0x56000004 = 0x00000000; *(volatile unsigned int *)0x56000008 = 0x00000000; *(volatile unsigned int *)0x5600000c = 0x00000000; *(volatile unsigned int *)0x56000010 = 0x002a9655; *(volatile unsigned int *)0x56000014 = 0x0000028e; *(volatile unsigned int *)0x56000018 = 0x000007ff; *(volatile unsigned int *)0x5600001c = 0x00000000; *(volatile unsigned int *)0x56000020 = 0xaaaaaaaa; *(volatile unsigned int *)0x56000024 = 0x00000000; *(volatile unsigned int *)0x56000028 = 0x0000ffff; *(volatile unsigned int *)0x5600002c = 0x00000000; *(volatile unsigned int *)0x56000030 = 0xaaaaaaaa; *(volatile unsigned int *)0x56000034 = 0x00000000; *(volatile unsigned int *)0x56000038 = 0x0000ffff; *(volatile unsigned int *)0x5600003c = 0x00000000; *(volatile unsigned int *)0x56000040 = 0xaaaaaaaa; *(volatile unsigned int *)0x56000044 = 0x0000cfe5; *(volatile unsigned int *)0x56000048 = 0x0000ffff; *(volatile unsigned int *)0x5600004c = 0x00000000; *(volatile unsigned int *)0x56000050 = 0x000055aa; *(volatile unsigned int *)0x56000054 = 0x00000005; *(volatile unsigned int *)0x56000058 = 0x000000ff; *(volatile unsigned int *)0x5600005c = 0x00000000; *(volatile unsigned int *)0x56000060 = 0xfd95ffba; *(volatile unsigned int *)0x56000064 = 0x0000b020; *(volatile unsigned int *)0x56000068 = 0x0000ffff; *(volatile unsigned int *)0x5600006c = 0x00000000; *(volatile unsigned int *)0x56000070 = 0x00000aa0; *(volatile unsigned int *)0x56000074 = 0x0000013c; *(volatile unsigned int *)0x56000078 = 0x000007ff; *(volatile unsigned int *)0x5600007c = 0x00000000; *(volatile unsigned int *)0x56000080 = 0x00010330; *(volatile unsigned int *)0x56000084 = 0x00000000; *(volatile unsigned int *)0x56000088 = 0x00000000; *(volatile unsigned int *)0x5600008c = 0x00000000; *(volatile unsigned int *)0x56000090 = 0x00000000; *(volatile unsigned int *)0x56000094 = 0x00000000; *(volatile unsigned int *)0x56000098 = 0x00000000; *(volatile unsigned int *)0x5600009c = 0x00000000; *(volatile unsigned int *)0x560000a0 = 0x00000000; *(volatile unsigned int *)0x560000a4 = 0x00fffff0; *(volatile unsigned int *)0x560000a8 = 0x00080b00; *(volatile unsigned int *)0x560000ac = 0x0000000b; *(volatile unsigned int *)0x560000b0 = 0x32440001; *(volatile unsigned int *)0x560000b4 = 0x00000001; *(volatile unsigned int *)0x560000b8 = 0x00000000; *(volatile unsigned int *)0x560000bc = 0x00000000; *(volatile unsigned int *)0x560000c0 = 0x00b00000; *(volatile unsigned int *)0x560000c4 = 0x00000000; *(volatile unsigned int *)0x560000c8 = 0x00000000; *(volatile unsigned int *)0x560000cc = 0x00000000; *(volatile unsigned int *)0x560000d0 = 0x02aaaaaa; *(volatile unsigned int *)0x560000d4 = 0x000007ff; *(volatile unsigned int *)0x560000d8 = 0x00000000; *(volatile unsigned int *)0x560000dc = 0x00000000; *(volatile unsigned int *)0x560000e0 = 0x00000000; *(volatile unsigned int *)0x560000e4 = 0x00000000; *(volatile unsigned int *)0x560000e8 = 0x00000000; *(volatile unsigned int *)0x560000ec = 0x00000000; *(volatile unsigned int *)0x560000f0 = 0x00000000; *(volatile unsigned int *)0x560000f4 = 0x00000000; *(volatile unsigned int *)0x560000f8 = 0x00000000; *(volatile unsigned int *)0x560000fc = 0x00000000; *(volatile unsigned int *)0x4c000000 = 0x00ffffff; *(volatile unsigned int *)0x4c000004 = 0x00044011; *(volatile unsigned int *)0x4c000008 = 0x00038042; *(volatile unsigned int *)0x4c00000c = 0x00fffff0; *(volatile unsigned int *)0x4c000010 = 0x00000004; *(volatile unsigned int *)0x4c000014 = 0x00000007; *(volatile unsigned int *)0x4c000018 = 0x00000000; *(volatile unsigned int *)0x4c00001c = 0x00000000; #endif puts("uboot init regs finished \n"); #if 0 *(volatile unsigned int *)0x56000020 = 0xaaaaaaaa; *(volatile unsigned int *)0x56000024 = 0x00000000; *(volatile unsigned int *)0x56000028 = 0x0000ffff; *(volatile unsigned int *)0x56000030 = 0xaaaaaaaa; *(volatile unsigned int *)0x56000034 = 0x00000000; *(volatile unsigned int *)0x56000038 = 0x0000ffff; #endif puts("vga init\n"); vga_init(); #if 1 puts("lcd init\n"); lcd_init(); lcd_clear_screen(0x000000); // black puts("lcd draw line\n"); lcd_draw_hline(100, 100, 640-100, 0xff0000); // red lcd_draw_hline(200, 100, 640-100, 0x00ff00); // green lcd_draw_hline(300, 100, 640-100, 0x0000ff); // blue lcd_draw_hline(400, 100, 640-100, 0xffffff); // white lcd_draw_vline(640/2, 50, 480-50, 0xffffff); // white #define POS 50 #define HALF 20 lcd_draw_cross(POS, POS, HALF); lcd_draw_cross(POS, 640-POS, HALF); lcd_draw_cross(480-POS, POS, HALF); lcd_draw_cross(480-POS, 640-POS, HALF); puts("lcd test over\n"); #endif //while (1); puts("nand init\n"); // nand read 16M (size = 1M) to sdram BMP_ADDR 0x33000000 nand_init(); // read bmp from 16M puts("nand read bmp 13M\n"); nand_read(0x1000000, BMP_ADDR, 0xD00000); puts("nand read bmp finished \n"); // read wav from 32M nand_read(0x2000000, WAV_ADDR, 0x100000); #if 0 // show BMP file puts("draw bmp file\n"); lcd_draw_bmp(BMP_ADDR); lcd_clear_screen(0x000000); // black puts("draw bmp file using DMA \n"); lcd_draw_bmp_to_mem(BMP_ADDR, 0x33800000); dma_memcpy(0x33800000, 0x32000000, 0xFFFFF); puts("draw bmp file finished \n"); audio_init(); puts("play wav file\n"); play_wav(WAV_ADDR); puts("play wav file finished \n"); puts("play wav file with DMA \n"); dma_play_wav2(WAV_ADDR); puts("play wav file with DMA finished \n"); #endif // deal with IRQ *(int *)0x18 = 0xE59ff000; // ldr pc, [pc] *(int *)0x20 = (int)dma_handler; // unmask INTMSK &= ~(1<<19); // enable CPSR IRQ-bit // write to CPSR with value 0x53 // CPSR = 0x53; __asm { msr CPSR_cxsf, #0x53 } while (1) { puts("while draw bmp file \n"); lcd_draw_bmp(BMP_ADDR); //lcd_clear_screen(0x000000); // black delay(); dma_clear_lcd(); } //while (1) { } while (1); return 0; }
int main(int argc, char **argv) { int option_index = 0; int c,i; int ch = 2; int rate = 44100; char *mmap = "N"; char *device = "hw:0,0"; char *filename; int rc = 0; if (argc <2) { printf("\nUsage: aplay [options] <file>\n" "options:\n" "-D <hw:C,D> -- Alsa PCM by name\n" "-M -- Mmap stream\n" "-P -- Hostless steam[No PCM]\n" "-C -- Channels\n" "-R -- Rate\n" "-V -- verbose\n" "-F -- Format\n" "-B -- Period\n" "-T <MP3, AAC, AC3_PASS_THROUGH> -- Compressed\n" "<file> \n"); fprintf(stderr, "Formats Supported:\n"); for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; ++i) if (get_format_name(i)) fprintf(stderr, "%s ", get_format_name(i)); fprintf(stderr, "\nSome of these may not be available on selected hardware\n"); return 0; } while ((c = getopt_long(argc, argv, "PVMD:R:C:F:B:T:", long_options, &option_index)) != -1) { switch (c) { case 'P': pcm_flag = 0; break; case 'V': debug = 1; break; case 'M': mmap = "M"; break; case 'D': device = optarg; break; case 'R': rate = (int)strtol(optarg, NULL, 0); break; case 'C': ch = (int)strtol(optarg, NULL, 0); break; case 'F': printf("optarg = %s\n", optarg); format = get_format(optarg); break; case 'B': period = (int)strtol(optarg, NULL, 0); break; case 'T': compressed = 1; printf("compressed codec type requested = %s\n", optarg); compr_codec = optarg; break; default: printf("\nUsage: aplay [options] <file>\n" "options:\n" "-D <hw:C,D> -- Alsa PCM by name\n" "-M -- Mmap stream\n" "-P -- Hostless steam[No PCM]\n" "-V -- verbose\n" "-C -- Channels\n" "-R -- Rate\n" "-F -- Format\n" "-B -- Period\n" "-T -- Compressed\n" "<file> \n"); fprintf(stderr, "Formats Supported:\n"); for (i = 0; i < SNDRV_PCM_FORMAT_LAST; ++i) if (get_format_name(i)) fprintf(stderr, "%s ", get_format_name(i)); fprintf(stderr, "\nSome of these may not be available on selected hardware\n"); return -EINVAL; } } filename = (char*) calloc(1, 30); if (!filename) { fprintf(stderr, "Aplay:Failed to allocate filename!"); return -ENOMEM; } if (optind > argc - 1) { free(filename); filename = NULL; } else { strlcpy(filename, argv[optind++], 30); } if (pcm_flag) { if (format == SNDRV_PCM_FORMAT_S16_LE) rc = play_wav(mmap, rate, ch, device, filename); else rc = play_raw(mmap, rate, ch, device, filename); } else { rc = play_wav(mmap, rate, ch, device, "dummy"); } if (filename) free(filename); return rc; }