* @brief Converts register string to integer * * @param str * @return unsigned long long int */
| 4109 | * @return unsigned long long int |
| 4110 | */ |
| 4111 | unsigned long long int |
| 4112 | RegisterToInt(char * str) |
| 4113 | { |
| 4114 | // |
| 4115 | // Check for register names |
| 4116 | // |
| 4117 | for (int i = 0; i < REGISTER_MAP_LIST_LENGTH; i++) |
| 4118 | { |
| 4119 | if (!strcmp(str, RegisterMapList[i].Name)) |
| 4120 | { |
| 4121 | return RegisterMapList[i].Type; |
| 4122 | } |
| 4123 | } |
| 4124 | |
| 4125 | // |
| 4126 | // Check for hwdbg register names |
| 4127 | // Check if the registers start with '@hw_portX' or '@hw_pinX' |
| 4128 | // |
| 4129 | if (g_HwdbgInstanceInfoIsValid) |
| 4130 | { |
| 4131 | const char * Ptr; |
| 4132 | UINT32 Num = 0; |
| 4133 | |
| 4134 | // |
| 4135 | // Check for "hw_pin" |
| 4136 | // |
| 4137 | if (strncmp(str, "hw_pin", 6) == 0) |
| 4138 | { |
| 4139 | Ptr = str + 6; |
| 4140 | if (*Ptr == '\0') |
| 4141 | { |
| 4142 | return INVALID; // No number present |
| 4143 | } |
| 4144 | while (*Ptr) |
| 4145 | { |
| 4146 | if (!isdigit((unsigned char)*Ptr)) |
| 4147 | { |
| 4148 | return INVALID; // Not a valid decimal number |
| 4149 | } |
| 4150 | Ptr++; |
| 4151 | } |
| 4152 | Num = atoi(str + 6); |
| 4153 | |
| 4154 | // |
| 4155 | // port numbers start after the latest pin number |
| 4156 | // |
| 4157 | if (Num >= g_HwdbgInstanceInfo.numberOfPins) |
| 4158 | { |
| 4159 | return INVALID; // Invalid "hw_pinX" |
| 4160 | } |
| 4161 | else |
| 4162 | { |
| 4163 | return Num; // Valid "hw_pinX" |
| 4164 | } |
| 4165 | } |
| 4166 | |
| 4167 | // |
| 4168 | // Check for "hw_port" |
no outgoing calls
no test coverage detected