Add toolchain and mbtk source
Change-Id: Ie12546301367ea59240bf23d5e184ad7e36e40b3
diff --git a/mbtk/mbtk_lib/src/mbtk_adc.c b/mbtk/mbtk_lib/src/mbtk_adc.c
new file mode 100755
index 0000000..222d828
--- /dev/null
+++ b/mbtk/mbtk_lib/src/mbtk_adc.c
@@ -0,0 +1,60 @@
+/**
+ * \file mbtk_adc.c
+ * \brief A Documented file.
+ *
+ * Detailed description
+ * \Author: js.wang <js.wang@mobiletek.cn>
+ * \Version: 1.0.0
+ * \Date: 2022-04-22
+ */
+#include <fcntl.h>
+#include <stdint.h>
+#include <limits.h>
+#include <termios.h>
+#include <stdarg.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+#include <sys/types.h>
+#include "mbtk_log.h"
+#include "mbtk_type.h"
+#include "mbtk_adc.h"
+
+#define ADC_DEVICE "/sys/devices/soc.0/d4000000.apb/pxa2xx-i2c.2/i2c-2/2-0030/pm802-bat/adc"
+
+int mbtk_adc_get(mbtk_adc_enum channle)
+{
+ int ret = 0;
+ int fd = 0;
+ char adc_buf[24] = {0};
+ char *adc_value = NULL;
+ char adc = (channle == MBTK_ADC0 ? '0' : '1');
+
+ fd = open(ADC_DEVICE, O_RDWR|O_CREAT|O_TRUNC, 0644);
+ if(fd < 0) {
+ LOGE("[%s] file open error\n", __FUNCTION__);
+ return -2;
+ }
+ ret = write(fd, &adc, 1);
+ if (ret < 0) {
+ LOGE("%s: error writing to file!\n", __FUNCTION__);
+ close(fd);
+ return -2;
+ }
+ ret = read(fd, adc_buf, 24);
+ if (ret < 0) {
+ LOGE("%s: error writing to file!\n", __FUNCTION__);
+ close(fd);
+ return -2;
+ }else{
+ LOGI("%s %d adc:%s\n", __FUNCTION__, __LINE__, adc_buf);
+ adc_value = strstr(adc_buf, "channel");
+ }
+ close(fd);
+ if(adc_value)
+ LOGI("%s adc: %s\n", __FUNCTION__, adc_value);
+ else
+ return -2;
+
+ return atoi(&adc_value[9]);
+}