Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
vector_int24.cpp@0:58277eb442ad, 2016-08-26 (annotated)
- Committer:
- cesarcazal
- Date:
- Fri Aug 26 21:33:39 2016 +0000
- Revision:
- 0:58277eb442ad
Librer?a de conversi?n de punteros (o vectores) a variables int32 (pero s?lo se toma como si fuesen equivalentes a int24)
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| cesarcazal | 0:58277eb442ad | 1 | |
| cesarcazal | 0:58277eb442ad | 2 | |
| cesarcazal | 0:58277eb442ad | 3 | #include "vector_int24.h" |
| cesarcazal | 0:58277eb442ad | 4 | #include "mbed.h" |
| cesarcazal | 0:58277eb442ad | 5 | //LOS VALORES SON DEVUELTOS EN FORMATO INT32; SIN EMBARGO SOLO SE REALIZAN CONVERSIONES EQUIVALENTES A VARIABLES DE 24BITS |
| cesarcazal | 0:58277eb442ad | 6 | |
| cesarcazal | 0:58277eb442ad | 7 | int32_t pointer_to_int32(uint8_t *vect) { |
| cesarcazal | 0:58277eb442ad | 8 | int aux1; |
| cesarcazal | 0:58277eb442ad | 9 | int32_t result=0; |
| cesarcazal | 0:58277eb442ad | 10 | for (aux1 = 2; aux1>0; aux1--){ |
| cesarcazal | 0:58277eb442ad | 11 | result= result|*(vect+aux1); |
| cesarcazal | 0:58277eb442ad | 12 | result <<= 8; |
| cesarcazal | 0:58277eb442ad | 13 | if((aux1==1)&&(*(vect+2)>127)) |
| cesarcazal | 0:58277eb442ad | 14 | result = result|(0xff000000); |
| cesarcazal | 0:58277eb442ad | 15 | } |
| cesarcazal | 0:58277eb442ad | 16 | result= *vect|result; |
| cesarcazal | 0:58277eb442ad | 17 | return (result); |
| cesarcazal | 0:58277eb442ad | 18 | } |
| cesarcazal | 0:58277eb442ad | 19 | |
| cesarcazal | 0:58277eb442ad | 20 | void int32_to_pointer (int32_t dato, uint8_t *point){ |
| cesarcazal | 0:58277eb442ad | 21 | *(point) = dato; |
| cesarcazal | 0:58277eb442ad | 22 | *(point+1) = dato>> 8; |
| cesarcazal | 0:58277eb442ad | 23 | *(point+2) = dato >> 16; |
| cesarcazal | 0:58277eb442ad | 24 | } |