Skip to content

Commit 18030bd

Browse files
author
Daniel Campora
committed
cc3200: Add own ubinascii module.
The reason to have our owm ubinascii module is so that later we can add crc32 support using the hardware engine.
1 parent 7bd273b commit 18030bd

5 files changed

Lines changed: 105 additions & 3 deletions

File tree

cc3200/application.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ APP_MISC_SRC_C = $(addprefix misc/,\
8787
APP_MODS_SRC_C = $(addprefix mods/,\
8888
modnetwork.c \
8989
moduhashlib.c \
90+
modubinascii.c \
9091
modpyb.c \
9192
moduos.c \
9293
modusocket.c \

cc3200/mods/modubinascii.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* This file is part of the Micro Python project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2014 Paul Sokolovsky
7+
* Copyright (c) 2015 Daniel Campora
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documentation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furnished to do so, subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in
17+
* all copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
#include "py/mpconfig.h"
29+
#include MICROPY_HAL_H
30+
#include "py/nlr.h"
31+
#include "py/runtime.h"
32+
#include "py/binary.h"
33+
#include "extmod/modubinascii.h"
34+
#include "modubinascii.h"
35+
#include "inc/hw_types.h"
36+
#include "inc/hw_ints.h"
37+
#include "inc/hw_nvic.h"
38+
#include "inc/hw_dthe.h"
39+
#include "hw_memmap.h"
40+
#include "rom_map.h"
41+
#include "prcm.h"
42+
#include "crc.h"
43+
#include "cryptohash.h"
44+
#include "mpexception.h"
45+
46+
47+
/******************************************************************************/
48+
// Micro Python bindings
49+
50+
STATIC const mp_map_elem_t mp_module_binascii_globals_table[] = {
51+
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_ubinascii) },
52+
{ MP_OBJ_NEW_QSTR(MP_QSTR_hexlify), (mp_obj_t)&mod_binascii_hexlify_obj },
53+
{ MP_OBJ_NEW_QSTR(MP_QSTR_unhexlify), (mp_obj_t)&mod_binascii_unhexlify_obj },
54+
};
55+
56+
STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globals_table);
57+
58+
const mp_obj_module_t mp_module_ubinascii = {
59+
.base = { &mp_type_module },
60+
.name = MP_QSTR_ubinascii,
61+
.globals = (mp_obj_dict_t*)&mp_module_binascii_globals,
62+
};

cc3200/mods/modubinascii.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file is part of the Micro Python project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2014 Paul Sokolovsky
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef MODUBINASCII_H_
28+
#define MODUBINASCII_H_
29+
30+
31+
#endif /* MODUBINASCII_H_ */

cc3200/mpconfigport.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
#define MICROPY_PY_CMATH (0)
7676
#define MICROPY_PY_IO (1)
7777
#define MICROPY_PY_IO_FILEIO (1)
78-
#define MICROPY_PY_UBINASCII (1)
78+
#define MICROPY_PY_UBINASCII (0)
7979
#define MICROPY_PY_UCTYPES (0)
8080
#define MICROPY_PY_UZLIB (0)
8181
#define MICROPY_PY_UJSON (1)
@@ -97,7 +97,6 @@ extern const struct _mp_obj_fun_builtin_t mp_builtin_open_obj;
9797

9898
// extra built in modules to add to the list of known ones
9999
extern const struct _mp_obj_module_t pyb_module;
100-
extern const struct _mp_obj_module_t mp_module_ubinascii;
101100
extern const struct _mp_obj_module_t mp_module_ure;
102101
extern const struct _mp_obj_module_t mp_module_ujson;
103102
extern const struct _mp_obj_module_t mp_module_uheapq;
@@ -106,6 +105,8 @@ extern const struct _mp_obj_module_t mp_module_utime;
106105
extern const struct _mp_obj_module_t mp_module_uselect;
107106
extern const struct _mp_obj_module_t mp_module_usocket;
108107
extern const struct _mp_obj_module_t mp_module_network;
108+
extern const struct _mp_obj_module_t mp_module_uhashlib;
109+
extern const struct _mp_obj_module_t mp_module_ubinascii;
109110

110111
#define MICROPY_PORT_BUILTIN_MODULES \
111112
{ MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
@@ -115,9 +116,9 @@ extern const struct _mp_obj_module_t mp_module_network;
115116
{ MP_OBJ_NEW_QSTR(MP_QSTR_usocket), (mp_obj_t)&mp_module_usocket }, \
116117
{ MP_OBJ_NEW_QSTR(MP_QSTR_network), (mp_obj_t)&mp_module_network }, \
117118
{ MP_OBJ_NEW_QSTR(MP_QSTR_uhashlib), (mp_obj_t)&mp_module_uhashlib }, \
119+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ubinascii), (mp_obj_t)&mp_module_ubinascii }, \
118120

119121
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
120-
{ MP_OBJ_NEW_QSTR(MP_QSTR_binascii), (mp_obj_t)&mp_module_ubinascii }, \
121122
{ MP_OBJ_NEW_QSTR(MP_QSTR_re), (mp_obj_t)&mp_module_ure }, \
122123
{ MP_OBJ_NEW_QSTR(MP_QSTR_json), (mp_obj_t)&mp_module_ujson }, \
123124
{ MP_OBJ_NEW_QSTR(MP_QSTR_heapq), (mp_obj_t)&mp_module_uheapq }, \
@@ -126,6 +127,7 @@ extern const struct _mp_obj_module_t mp_module_network;
126127
{ MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_module_uselect }, \
127128
{ MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&mp_module_usocket }, \
128129
{ MP_OBJ_NEW_QSTR(MP_QSTR_hashlib), (mp_obj_t)&mp_module_uhashlib }, \
130+
{ MP_OBJ_NEW_QSTR(MP_QSTR_binascii), (mp_obj_t)&mp_module_ubinascii }, \
129131

130132
// extra constants
131133
#define MICROPY_PORT_CONSTANTS \

cc3200/qstrdefsport.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,9 @@ Q(digest)
357357
//Q(md5)
358358
Q(sha1)
359359
Q(sha256)
360+
361+
// for ubinascii module
362+
Q(ubinascii)
363+
Q(hexlify)
364+
Q(unhexlify)
365+

0 commit comments

Comments
 (0)