2009年9月16日水曜日

xclexeのリリース

I made the program for clipboard extension of Linux

everything xclexe can do is just keep watching the clipboard , and throw it to specific application by the rule.
Don't worry about you are no idea of the rule. Just execute it, and then you will get the sample under the $HOME/.xclexe

[global]
#x=50
#y=50
#width=840
#height=70
#border_width=2

[exec]
#PATH=/usr/bin/ed2k
#KEYWORD=ed2k:
#FLAG=1

There are 2 section in rule file, The first one is [global], you can define the windows size and position at here.
And second one is [exec], you can define the specific application rule at here. if you have one more rule just need to append a new [exec] section.

For example.
[exec]
PATH=/usr/bin/ed2k
KEYWORD=ed2k:
FLAG=1

PATH means specific application path.
KEYWORD means the keyword of clipboard content.
FLAG means searching rule, 1 means check the content head, 2 means check the content end, 0 - means search the keyword.

The sample means keep check the clipboard content, if the content begin with "edk2:" string,
Then clipboard content would be the first parameter execute by the /usr/bin/ed2k.
Translate to the comand line is:
/usr/bin/ed2k

BTW, # means comment out.

enjoy it!

you can download the sources from the URL
http://file7.brsbox.com/download.php?sid=cd48f0bb55ece2d19cb4329a866bfbab&fc=e63d5a4a126d0ad675631a5688bdf375/xclexe.tar.gz

2009年8月13日木曜日

Cortextと関係ないですが(その1)

子供を生まれったので、最近はものすごく忙しくで、せかくstm32f107のチープをもらったのに、試しの時間もなくなった...
父は大変よ~~~
まぁ~~最近linuxの仕事ばかりやっているので、Linuxの情報をメモしたいと思う

①Fedora11のSELINUXを止まれ
# vi /etc/sysconfig/selinux
SELINUX=disabled
保存してから再起動

②Fedora11でiptableを止まれ
# /etc/init.d/iptables stop

③Fedora11でWineで作ったプログラムをサービスとして登録
スクリプトのサンプルが下記の通り
#!/bin/bash
# chkconfig: 35 99 1
# 上記の一行はchkconfig専用、ない登録できない
progname=service

# wineのプログラムをデーモンで実行させるように、作ったプログラム、ソースは面倒から添付しない
# 原理は簡単、fork関数だけ
wineloader=/usr/local/bin/wineloader

#サービスのパス
prog=/usr/local/bin/service

# wineがrootで実行すると、かなり危険ので、通常のユーザで登録
user=kevinx

# Source function library.
#このファイルにいい関数がいっぱい入っている、Fedora11特有
. /etc/init.d/functions

RETVAL=0

start() {
echo -n $"Starting $progname: "
daemon --user $user $wineloader -e $prog
RETVAL=$?
return $RETVAL
}

stop() {
echo -n $"Stopping $progname: "
killproc $prog
RETVAL=$?
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
esac

exit $RETVAL

登録命令
chkconfig --add service

スクリプトの参照URLは
http://www.geocities.co.jp/SiliconValley-Cupertino/9120/startup.html
http://surf.ap.seikei.ac.jp/~nakano/linux/init.d.html
wineloaderの参照URLは
http://d.hatena.ne.jp/rero/20041002/p1

つづく...

2009年7月4日土曜日

Linuxのusb sniffer

昔Windowsの場合、USBのドライバを開発するとき、BUS Houndを使ってUSB通信パケットをキャプチャできるんですが、今Linuxの環境で同じようなものを探します。
結局、カーネルでCONFIG_DEBUG_FSとCONFIG_USB_MONのオプションを有効すれば、何もインストールしなくでも簡単にできるです。
命令が下記のとおり:
# mount -t debugfs none /sys/kernel/debug
# cat /sys/kernel/debug/usbmon/0u
ここ0uの意味は全通信を監視
特定のデバイスを監視の場合が、そのデバイス対応しているの番号を使います。
ちなみに、番号確認命令はlsusbです。
詳しい情報が下記のURLを参照
http://pylone.jp/blog/tips_usbmon

2009年6月30日火曜日

VIMが大好き!

最初はVIMのこと使いにくいと思いました。
少しつつ勉強しながら、大好きになりました。
やはり、メインキーボードだけ、なんでもできるのはかっこういいでしょう ^^

VIMでtagの使い方を探していた時、下記のURLを見つかりました。
ありがとう、勉強になりました!

2009年6月26日金曜日

NVICの優先順位について

ここ参照します。
http://blog.ednchina.com/STM32/143803/message.aspx

簡単に言えば、STM32の優先グループが五つのモードがあります。

/* 0 bits for pre-emption priority 4 bits for subpriority */
#define NVIC_PriorityGroup_0 ((u32)0x700)

/* 1 bits for pre-emption priority 3 bits for subpriority */
#define NVIC_PriorityGroup_1 ((u32)0x600)

/* 2 bits for pre-emption priority 2 bits for subpriority */
#define NVIC_PriorityGroup_2 ((u32)0x500)

/* 3 bits for pre-emption priority 1 bits for subpriority */
#define NVIC_PriorityGroup_3 ((u32)0x400)

/* 4 bits for pre-emption priority 0 bits for subpriority */
#define NVIC_PriorityGroup_4 ((u32)0x300)

割り込みを発生する時、優先順位高いの関数が優先順位低いの関数を中断して先に実行する。

pre-emptionの数字が低いの方が優先順位が高い、例えば:0が1より優先が高い。
pre-emptionは同じの場合、subpriorityの数字を確認する、小さいの方が高い。

わたしのコードが下記を示す

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN_RX0_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

/* Enable USART1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_Init(&NVIC_InitStructure);

/* Enable the DMA1 Channel1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

優先1、USART1
優先2、USB
優先3、DMA1

2009年6月22日月曜日

ADCのサンプルコード

ANALOG INPUT:PA.4(ADC_AIN_CHANNEL_X)、PC.4(ADC_AIN_CHANNEL_Y)、PC.5(ADC_AIN_CHANNEL_Z)
DMA1を利用して、X Y Z情報がADC1_DR_AddressからADC_ConvertedValueXに自動保存します。
ADC_ConvertedValueX[0]=X
ADC_ConvertedValueX[1]=Y
ADC_ConvertedValueX[2]=Z

サンプルコードが下記に示す。

void ADC_Configuration(void)
{
ADC_InitTypeDef ADC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;

/* Enable DMA1 clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);

/* Enable ADC1 clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

/* DMA1 channel1 configuration ---------------------------------------------*/
DMA_DeInit(DMA1_Channel1);
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValueX[0];
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = 3;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;/*DMA_MemoryInc_Disable;*/
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel1, &DMA_InitStructure);

/* Enable DMA1 channel1 */
DMA_Cmd(DMA1_Channel1, ENABLE);

/* Enable the DMA1 Channel1 Transfer complete interrupt */
DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE);

/* ADC1 configuration ------------------------------------------------------*/
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 3;
ADC_Init(ADC1, &ADC_InitStructure);

/* ADC1 regular channel configuration */
ADC_RegularChannelConfig(ADC1, ADC_AIN_CHANNEL_X, 1, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_AIN_CHANNEL_Y, 2, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_AIN_CHANNEL_Z, 3, ADC_SampleTime_55Cycles5);

/* Enable ADC1 DMA */
ADC_DMACmd(ADC1, ENABLE);

/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);

/* Enable ADC1 reset calibaration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));

/* Start ADC1 calibaration */
ADC_StartCalibration(ADC1);

/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
}

今、OpenJTAGを使ってデバック環境でX、Y、Z情報をきちんと取りますが、デバッグ以外の場合がDMA1の割り込みを発生しません。
何で?