osAiSetFrequency.c (880B)
1 #include "libultra_internal.h" 2 #include "PR/rcp.h" 3 #include "osint.h" 4 #include "macros.h" 5 6 s32 osAiSetFrequency(u32 freq) { 7 register u32 dacRate; 8 #ifdef VERSION_CN 9 register u32 bitRate; 10 #else 11 register s32 bitRate; 12 #endif 13 register float ftmp; 14 ftmp = osViClock / (float) freq + .5f; 15 16 dacRate = ftmp; 17 18 if (dacRate < AI_MIN_DAC_RATE) { 19 return -1; 20 } 21 22 bitRate = (dacRate / 66) & 0xff; 23 if (bitRate > AI_MAX_BIT_RATE) { 24 bitRate = AI_MAX_BIT_RATE; 25 } 26 27 IO_WRITE(AI_DACRATE_REG, dacRate - 1); 28 IO_WRITE(AI_BITRATE_REG, bitRate - 1); 29 #ifndef VERSION_CN 30 IO_WRITE(AI_CONTROL_REG, AI_CONTROL_DMA_ON); 31 #endif 32 return osViClock / (s32) dacRate; 33 } 34 35 #if !defined(VERSION_SH) && !defined(VERSION_CN) 36 // put some extra jr $ra's down there please 37 UNUSED static void filler1(void) { 38 } 39 40 UNUSED static void filler2(void) { 41 } 42 #endif