diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2010-11-08 23:23:00 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2010-11-08 23:23:00 +0000 |
commit | 598f56ecb241fa65f0e13e826add006e9cc55676 (patch) | |
tree | 6bef060d7be4956ad1a8e9ca24f9b599bf900400 | |
parent | 0322ab1d194cb9e3b3d0f0925ccc7c9edfb8c254 (diff) | |
download | rockbox-598f56ecb241fa65f0e13e826add006e9cc55676.tar.gz rockbox-598f56ecb241fa65f0e13e826add006e9cc55676.zip |
Simplify unsigned int <-> unsigned char array conversion in ipod_remote_tuner.c (make it endianness independent)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28537 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/tuner/ipod_remote_tuner.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/firmware/drivers/tuner/ipod_remote_tuner.c b/firmware/drivers/tuner/ipod_remote_tuner.c index 92fcd902ab..a7a16c5217 100644 --- a/firmware/drivers/tuner/ipod_remote_tuner.c +++ b/firmware/drivers/tuner/ipod_remote_tuner.c | |||
@@ -47,11 +47,6 @@ static bool rds_event = false; | |||
47 | static char rds_radioname[9]; | 47 | static char rds_radioname[9]; |
48 | static char rds_radioinfo[65]; | 48 | static char rds_radioinfo[65]; |
49 | 49 | ||
50 | static union FRQ { | ||
51 | unsigned long int frequency_radio; | ||
52 | char data_frequency[4]; | ||
53 | }Frequency; | ||
54 | |||
55 | static void rmt_tuner_signal_power(unsigned char value) | 50 | static void rmt_tuner_signal_power(unsigned char value) |
56 | { | 51 | { |
57 | tuner_signal_power = (int)(value); | 52 | tuner_signal_power = (int)(value); |
@@ -59,14 +54,9 @@ static void rmt_tuner_signal_power(unsigned char value) | |||
59 | 54 | ||
60 | void rmt_tuner_freq(const unsigned char *serbuf) | 55 | void rmt_tuner_freq(const unsigned char *serbuf) |
61 | { | 56 | { |
62 | char tempdata[4]; | 57 | unsigned int khz = (serbuf[3] << 24) | (serbuf[4] << 16) | |
63 | tempdata[0] = serbuf[6]; | 58 | (serbuf[5] << 8) | serbuf[6]; |
64 | tempdata[1] = serbuf[5]; | 59 | tuner_frequency = khz *1000 ; |
65 | tempdata[2] = serbuf[4]; | ||
66 | tempdata[3] = serbuf[3]; | ||
67 | |||
68 | memcpy(Frequency.data_frequency,tempdata,4); | ||
69 | tuner_frequency = (Frequency.frequency_radio*1000); | ||
70 | radio_tuned = true; | 60 | radio_tuned = true; |
71 | rmt_tuner_signal_power(serbuf[7]); | 61 | rmt_tuner_signal_power(serbuf[7]); |
72 | } | 62 | } |
@@ -85,16 +75,11 @@ static void rmt_tuner_set_freq(int curr_freq) | |||
85 | 75 | ||
86 | if (curr_freq != 0) | 76 | if (curr_freq != 0) |
87 | { | 77 | { |
88 | curr_freq = curr_freq / 1000; | 78 | unsigned int khz = curr_freq / 1000; |
89 | char tempdata[4]; | 79 | data[2] = (khz >> 24) & 0xFF; |
90 | 80 | data[3] = (khz >> 16) & 0xFF; | |
91 | Frequency.frequency_radio = curr_freq; | 81 | data[4] = (khz >> 8) & 0xFF; |
92 | tempdata[0] = Frequency.data_frequency[3]; | 82 | data[5] = (khz >> 0) & 0xFF; |
93 | tempdata[1] = Frequency.data_frequency[2]; | ||
94 | tempdata[2] = Frequency.data_frequency[1]; | ||
95 | tempdata[3] = Frequency.data_frequency[0]; | ||
96 | |||
97 | memcpy(data+2,tempdata,4); | ||
98 | iap_send_pkt(data, sizeof(data)); | 83 | iap_send_pkt(data, sizeof(data)); |
99 | } | 84 | } |
100 | } | 85 | } |