| 147 | #ifdef RT_USING_FINSH |
| 148 | |
| 149 | static int dac(int argc, char **argv) |
| 150 | { |
| 151 | int result = RT_EOK; |
| 152 | static rt_dac_device_t dac_device = RT_NULL; |
| 153 | char *result_str; |
| 154 | |
| 155 | if (argc > 1) |
| 156 | { |
| 157 | if (!strcmp(argv[1], "probe")) |
| 158 | { |
| 159 | if (argc == 3) |
| 160 | { |
| 161 | dac_device = (rt_dac_device_t)rt_device_find(argv[2]); |
| 162 | result_str = (dac_device == RT_NULL) ? "failure" : "success"; |
| 163 | rt_kprintf("probe %s %s \n", argv[2], result_str); |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | rt_kprintf("dac probe <dac_name> - probe dac by name\n"); |
| 168 | } |
| 169 | } |
| 170 | else |
| 171 | { |
| 172 | if (dac_device == RT_NULL) |
| 173 | { |
| 174 | rt_kprintf("Please using 'dac probe <dac_name>' first\n"); |
| 175 | return -RT_ERROR; |
| 176 | } |
| 177 | if (!strcmp(argv[1], "enable")) |
| 178 | { |
| 179 | if (argc == 3) |
| 180 | { |
| 181 | result = rt_dac_enable(dac_device, atoi(argv[2])); |
| 182 | result_str = (result == RT_EOK) ? "success" : "failure"; |
| 183 | rt_kprintf("%s channel %d enables %s \n", dac_device->parent.parent.name, atoi(argv[2]), result_str); |
| 184 | } |
| 185 | else |
| 186 | { |
| 187 | rt_kprintf("dac enable <channel> - enable dac channel\n"); |
| 188 | } |
| 189 | } |
| 190 | else if (!strcmp(argv[1], "write")) |
| 191 | { |
| 192 | if (argc == 4) |
| 193 | { |
| 194 | rt_dac_write(dac_device, atoi(argv[2]), atoi(argv[3])); |
| 195 | rt_kprintf("%s channel %d write value is %d \n", dac_device->parent.parent.name, atoi(argv[2]), atoi(argv[3])); |
| 196 | } |
| 197 | else |
| 198 | { |
| 199 | rt_kprintf("dac write <channel> <value> - write dac value on the channel\n"); |
| 200 | } |
| 201 | } |
| 202 | else if (!strcmp(argv[1], "disable")) |
| 203 | { |
| 204 | if (argc == 3) |
| 205 | { |
| 206 | result = rt_dac_disable(dac_device, atoi(argv[2])); |
nothing calls this directly
no test coverage detected