mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Merge branch 'upsilon-new-bootloader' of https://github.com/devdl11/Upsilon into upsilon-new-bootloader
This commit is contained in:
@@ -10,8 +10,7 @@ void swap(char *x, char *y) {
|
||||
}
|
||||
|
||||
// Function to reverse `buffer[i…j]`
|
||||
char* reverse(char *buffer, int i, int j)
|
||||
{
|
||||
char* reverse(char *buffer, int i, int j) {
|
||||
while (i < j) {
|
||||
swap(&buffer[i++], &buffer[j--]);
|
||||
}
|
||||
@@ -20,8 +19,7 @@ char* reverse(char *buffer, int i, int j)
|
||||
}
|
||||
|
||||
// Iterative function to implement `itoa()` function in C
|
||||
char* Bootloader::Utility::itoa(int value, char* buffer, int base)
|
||||
{
|
||||
char* Bootloader::Utility::itoa(int value, char* buffer, int base) {
|
||||
// invalid input
|
||||
if (base < 2 || base > 32) {
|
||||
return buffer;
|
||||
@@ -31,8 +29,7 @@ char* Bootloader::Utility::itoa(int value, char* buffer, int base)
|
||||
int n = abs(value);
|
||||
|
||||
int i = 0;
|
||||
while (n)
|
||||
{
|
||||
while (n) {
|
||||
int r = n % base;
|
||||
|
||||
if (r >= 10) {
|
||||
@@ -61,4 +58,4 @@ char* Bootloader::Utility::itoa(int value, char* buffer, int base)
|
||||
|
||||
// reverse the string and return it
|
||||
return reverse(buffer, 0, i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,4 +36,4 @@ const Bootloader::USBData Bootloader::USBData::BOOTLOADER_UPDATE() {
|
||||
|
||||
Bootloader::USBData Bootloader::USBData::Recovery(uint32_t startAddress, uint32_t size) {
|
||||
return USBData(buildStringDescriptor(StringHeader::SRAM(), startAddress, size), Messages::upsilonRecovery, ProtectionState(false, false));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user