Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cpcap: add macro test command, tested for blinking led

Change-Id: I387e879b153de07e537d01a9bafad8e7a0096bf1
  • Loading branch information...
commit 69a5bb36aa682d82f0a6e81811e090601046204c 1 parent 7c987ae
@tpruvot authored
Showing with 75 additions and 11 deletions.
  1. +49 −11 cpcap/cpcap.c
  2. +26 −0 cpcap/cpcap.h
View
60 cpcap/cpcap.c
@@ -45,6 +45,35 @@ int read_bank(int bank, int format) {
return ret;
}
+
+/**
+ * start/stop cpcap macros
+ */
+int macro_uc(int macro, int enable) {
+ int ret;
+
+ int cpcap_uc = open("/dev/cpcap_uc", O_RDWR | O_NONBLOCK);
+ if (cpcap_uc <= 0) {
+ fprintf(stderr, "%s: failed, errno=%d\n", __func__, errno);
+ return -errno;
+ }
+
+ if (enable)
+ ret = ioctl(cpcap_uc, CPCAP_IOCTL_UC_MACRO_START, macro);
+ else
+ ret = ioctl(cpcap_uc, CPCAP_IOCTL_UC_MACRO_STOP, macro);
+
+ if (ret != 0) {
+ fprintf(stderr, "%s: ioctl failed, ret=%d errno=%d\n", __func__, ret, errno);
+ return ret;
+ }
+
+ close(cpcap_uc);
+
+ return ret;
+}
+
+
/**
* Read battery data, doesnt works (blank, no error)
*/
@@ -61,7 +90,7 @@ int read_batt_ps() {
ret = ioctl(cpcap_fd, CPCAP_IOCTL_BATT_DISPLAY_UPDATE, &batt_state);
if (ret != 0) {
- fprintf(stderr, "%s: ioctl failed, ret=%d errno=%d", __func__, ret, errno);
+ fprintf(stderr, "%s: ioctl failed, ret=%d errno=%d\n", __func__, ret, errno);
return ret;
}
@@ -92,8 +121,8 @@ int main(int argc, char **argv) {
printf("\n");
printf("commands:\n");
printf("\n");
- printf(" volt <source> Get current battery voltage (mV)\n");
- printf(" source : batt/battpi/average\n");
+ printf(" volt <source> Get current voltage (mV)\n");
+ printf(" source : batt/vbus/battpi\n");
printf("\n");
printf(" dump <format> Dump ADC registers\n");
printf(" format : all/raw/phase/convert\n");
@@ -215,15 +244,15 @@ int main(int argc, char **argv) {
printf("%d\n", req_us.result[CPCAP_ADC_BATTP]);
}
- /* volt battpi : battery voltage too */
- if (!strcmp(argv[1], "volt") && !strcmp(argv[2], "battpi"))
+ /* volt vbus : +5V line (4400 or more on ac/usb, else 4000 to 4400) */
+ if (!strcmp(argv[1], "volt") && !strcmp(argv[2], "vbus"))
{
- ret = read_bank(CPCAP_ADC_TYPE_BATT_PI, CPCAP_ADC_FORMAT_CONVERTED);
- printf("%d\n", req_us.result[0]);
+ ret = read_bank(CPCAP_ADC_TYPE_BANK_0, CPCAP_ADC_FORMAT_CONVERTED);
+ printf("%d\n", req_us.result[CPCAP_ADC_VBUS]);
}
- /* volt batt : battery voltage based on 4 (last?) values */
- if (!strcmp(argv[1], "volt") && !strcmp(argv[2], "average"))
+ /* volt battpi : battery voltage based on 4 (last?) values */
+ if (!strcmp(argv[1], "volt") && !strcmp(argv[2], "battpi"))
{
int tot = 0;
ret = read_bank(CPCAP_ADC_TYPE_BATT_PI, CPCAP_ADC_FORMAT_CONVERTED);
@@ -233,9 +262,18 @@ int main(int argc, char **argv) {
printf("%d\n", tot / 4);
}
- //buggy, all is zero
+
+ // buggy, all is zero and breaks system battery report
if (!strcmp(argv[1], "batt") && !strcmp(argv[2], "data")) {
- read_batt_ps();
+ read_batt_ps();
+ }
+
+ if (!strcmp(argv[1], "macro") && argc >= 4) {
+ int macro = atoi(argv[2]);
+ int enable = atoi(argv[3]);
+
+ printf("%s macro %d...\n", enable?"start":"stop", macro);
+ ret = macro_uc(macro, enable);
}
close(cpcap_fd);
View
26 cpcap/cpcap.h
@@ -19,4 +19,30 @@ struct cpcap_batt_data_mb525 {
int batt_capacity_one;
};
+
+/*
+Tegra2 (atrix) use two banks of macros
+
+enum cpcap_macro { // bank 1 bank 2
+ CPCAP_MACRO_ROMR,
+ CPCAP_MACRO_RAMW,
+ CPCAP_MACRO_RAMR,
+ CPCAP_MACRO_USEROFF,
+ CPCAP_MACRO_4, // uc init like 12 (after fw upload) standby
+ CPCAP_MACRO_5, // 3mm5, like 13 standby
+ CPCAP_MACRO_6, // rgb led blinking kick the watchdog
+ CPCAP_MACRO_7,
+ CPCAP_MACRO_8,
+ CPCAP_MACRO_9,
+ CPCAP_MACRO_10,
+ CPCAP_MACRO_11,
+ CPCAP_MACRO_12, // uc ST only REG_MI2
+ CPCAP_MACRO_13, // 3mm5 ST only
+ CPCAP_MACRO_14, // pm debug TI REG_MIM1 / ST REG_MI2 REG_MI2
+ CPCAP_MACRO_15,
+
+ CPCAP_MACRO__END,
+};
+*/
+
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.