00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 import os
00016 Import('buildTargets env')
00017
00018
00019
00020
00021
00022
00023
00024
00025 PIC24SupportLibSources = [
00026 'common/pic24_adc.c',
00027 'common/pic24_clockfreq.c',
00028 'common/pic24_configbits.c',
00029 'common/pic24_ecan.c',
00030 'common/pic24_flash.c',
00031 'common/pic24_i2c.c',
00032 'common/pic24_serial.c',
00033 'common/pic24_spi.c',
00034 'common/pic24_timer.c',
00035 'common/pic24_uart.c',
00036 'common/pic24_util.c' ]
00037
00038
00039
00040 SConscript('./templates/SConscript.py', 'env')
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 def buildProgramWithCommonSources(sourceFileList, commonSources, buildEnvironment,
00059 aliasString):
00060 be = buildEnvironment
00061 be.Program(sourceFileList + commonSources)
00062
00063 f = os.path.splitext(sourceFileList[0])[0]
00064 myHex = be.Hex(f, f)
00065
00066 be.Alias(aliasString, myHex)
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 def buildWithCommonSources(sourceFileList, commonSources, buildEnvironment,
00083 exceptionDict, aliasString):
00084 for sourceFileGlob in sourceFileList:
00085 for sourceFile in Glob(sourceFileGlob, True, True, True):
00086
00087 if sourceFile in exceptionDict:
00088
00089 be = buildEnvironment.Clone()
00090 flags = exceptionDict[sourceFile]
00091
00092
00093
00094
00095 for a in flags:
00096 be[a] = flags[a]
00097 else:
00098
00099 be = buildEnvironment
00100 buildProgramWithCommonSources([sourceFile], commonSources, be,
00101 aliasString)
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 def buildWithCommonLibs(sourceFileList, commonLibs, buildEnvironment):
00114 for sourceFileGlob in sourceFileList:
00115 for sourceFile in Glob(sourceFileGlob, True, True, True):
00116 f=os.path.splitext(sourceFile)[0]
00117 print sourceFile, f, commonLibs
00118 buildEnvironment.Program([sourceFile], LIBS=commonLibs)
00119 myHex = buildEnvironment.Hex(f,f)
00120 Depends( myHex, commonLibs)
00121
00122
00123
00124
00125 myLib = env.StaticLibrary(target='lib/msu_pic24', source=PIC24SupportLibSources )
00126
00127
00128
00129
00130
00131 if 'lib11' in COMMAND_LINE_TARGETS:
00132
00133 env.Program(['chap11/dac_r2r.c'] + PIC24SupportLibSources)
00134 env.Hex('chap11/dac_r2r','chap11/dac_r2r')
00135
00136
00137
00138
00139 PIC24SupportLibObjects = env.Object(PIC24SupportLibSources)
00140
00141 if 'reset' in buildTargets:
00142 buildWithCommonSources(['chap8/reset.c'], PIC24SupportLibObjects, env, {}, 'reset')
00143 if 'chap8' in buildTargets:
00144 buildWithCommonSources(['chap8/*.c'], PIC24SupportLibObjects, env, {}, 'chap8')
00145 if 'chap9' in buildTargets:
00146 buildWithCommonSources(['chap9/*.c'], PIC24SupportLibObjects, env, {}, 'chap9')
00147 if 'chap10' in buildTargets:
00148 buildWithCommonSources(['chap10/*.c'], PIC24SupportLibObjects, env,
00149 {'chap10\\reverse_string.c' : { 'CPPDEFINES': 'UART1_RX_INTERRUPT'},
00150 'chap10\\reverse_string1.c' : { 'CPPDEFINES': ['UART1_RX_INTERRUPT', 'UART1_TX_INTERRUPT']}},
00151 'chap10')
00152 if 'chap11' in buildTargets:
00153 buildWithCommonSources(['chap11/*.c'], PIC24SupportLibObjects, env, {}, 'chap11')
00154 if 'chap12' in buildTargets:
00155 buildWithCommonSources(['chap12/*.c'], PIC24SupportLibObjects, env, {}, 'chap12')
00156 if 'chap13' in buildTargets:
00157 buildWithCommonSources(['chap13/*.c'], PIC24SupportLibObjects, env,
00158 {'chap13\\i2c_multmaster_rstring.c' : { 'CPPDEFINES': 'CPU_ID=1' },
00159 'chap13\\i2c_multmaster_rstring1.c' : { 'CPPDEFINES': 'CPU_ID=2' }},
00160 'chap13')
00161 if 'chap14' in buildTargets:
00162 buildWithCommonSources(['chap14/*.c'], PIC24SupportLibObjects, env, {}, 'chap14')
00163 if 'chap15' in buildTargets:
00164
00165 buildProgramWithCommonSources(['chap15/audio.c', 'chap15/audio_adpcm.c', ],
00166 PIC24SupportLibObjects, env, 'chap15')
00167 buildProgramWithCommonSources(['chap15/reflow_oven.c', 'chap15/reflow_debug.c',
00168 'chap15/reflow_flash.c', 'chap15/reflow_operate.c'], PIC24SupportLibObjects,
00169 env, 'chap15')
00170 buildProgramWithCommonSources(['chap15/robot.c', 'chap15/robot_ir_decode.c', ],
00171 PIC24SupportLibObjects, env, 'chap15')
00172 if 'explorer' in buildTargets:
00173 buildWithCommonSources(['explorer16_100p/*.c'], PIC24SupportLibObjects, env, {}, 'explorer')
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193